mirror of
https://github.com/nasa/trick.git
synced 2025-02-20 09:16:20 +00:00
gxplot depends on Motif
Removed all motif dependencies. I removed the motif based table renderer that is duplicated here in gxplot. The same table renderer is in fxplot with one main difference, the one in fxplot actually renders tables, this one was not working. Also removed an error message dialog box that depended on motif, replacing them with std::cerr calls. Removed -lXm when linking gxplot refs #121
This commit is contained in:
parent
80b8f99723
commit
7523c7b36c
@ -76,27 +76,7 @@ DPV_pointer gnuplot_view::render_page( DPV_pointer parent_data,
|
||||
// MEMBER FUNCTION
|
||||
DPV_pointer gnuplot_view::render_table( DPV_pointer parent_data,
|
||||
DPC_table* table) {
|
||||
|
||||
TableViewNode *table_view_node;
|
||||
//int table_number;
|
||||
|
||||
GPViewProductNode *product_view_node = (GPViewProductNode*)parent_data;
|
||||
|
||||
if ((xpos + width) >= WidthOfScreen( XtScreen(toplevel))) {
|
||||
xpos = 100;
|
||||
}
|
||||
if ((ypos + height) >= HeightOfScreen( XtScreen(toplevel))) {
|
||||
ypos = 100;
|
||||
}
|
||||
|
||||
table_view_node = new TableViewNode(toplevel, table, xpos, ypos, width, height);
|
||||
|
||||
xpos += 20;
|
||||
ypos += 20;
|
||||
|
||||
product_view_node->table_node_list.push_back( table_view_node );
|
||||
|
||||
return( (DPV_pointer)table_view_node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// MEMBER FUNCTION
|
||||
@ -192,13 +172,7 @@ void gnuplot_view::finalize_page_view( DPV_pointer page_view ) {
|
||||
}
|
||||
|
||||
// MEMBER FUNCTION
|
||||
void gnuplot_view::finalize_table_view( DPV_pointer table_view ) {
|
||||
|
||||
TableViewNode* table_view_node = (TableViewNode *)table_view;
|
||||
|
||||
table_view_node->finalize();
|
||||
|
||||
}
|
||||
void gnuplot_view::finalize_table_view( DPV_pointer table_view ) { }
|
||||
|
||||
// MEMBER FUNCTION
|
||||
void gnuplot_view::finalize_plot_view( DPV_pointer plot_view ) {
|
||||
@ -225,8 +199,7 @@ void gnuplot_view::update_finalize_plot_view( DPV_pointer plot_view ) {
|
||||
void gnuplot_view::notify_product( DPV_pointer product_view, DPV_message msg ) {
|
||||
|
||||
GPViewPageNode *page_view_node;
|
||||
TableViewNode *table_view_node;
|
||||
int i, n_pages, n_tables;
|
||||
int i, n_pages;
|
||||
|
||||
GPViewProductNode *product_view_node = (GPViewProductNode *)product_view;
|
||||
|
||||
@ -235,13 +208,6 @@ void gnuplot_view::notify_product( DPV_pointer product_view, DPV_message msg ) {
|
||||
page_view_node = product_view_node->page_node_list[i];
|
||||
notify_page( (DPV_pointer)page_view_node, msg );
|
||||
}
|
||||
|
||||
n_tables = (int)product_view_node->table_node_list.size();
|
||||
for (i=0 ; i<n_tables ; i++ ) {
|
||||
table_view_node = product_view_node->table_node_list[i];
|
||||
notify_table( (DPV_pointer)table_view_node, msg );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MEMBER FUNCTION
|
||||
@ -269,19 +235,7 @@ void gnuplot_view::notify_page( DPV_pointer page_view, DPV_message msg ) {
|
||||
}
|
||||
|
||||
// MEMBER FUNCTION
|
||||
void gnuplot_view::notify_table( DPV_pointer table_view, DPV_message msg ) {
|
||||
|
||||
Widget table_widget;
|
||||
TableViewNode *table_view_node = (TableViewNode *)table_view;
|
||||
|
||||
if (msg == RAISE_WINDOW) {
|
||||
table_widget = table_view_node->dialog_shell_widget;
|
||||
if (table_widget != NULL ) {
|
||||
XRaiseWindow( XtDisplay(table_widget), XtWindow(table_widget));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void gnuplot_view::notify_table( DPV_pointer table_view, DPV_message msg ) { }
|
||||
|
||||
// MEMBER FUNCTION
|
||||
void gnuplot_view::notify_plot( DPV_pointer plot_view, DPV_message msg ) {
|
||||
|
@ -3,12 +3,10 @@
|
||||
#define GP_VIEW_HH
|
||||
|
||||
#include "DPV/DPV_view.hh"
|
||||
#include <Xm/Xm.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "gp_view_curve_node.hh"
|
||||
#include "gp_view_plot_node.hh"
|
||||
#include "table_view_node.hh"
|
||||
#include "gp_view_page_node.hh"
|
||||
#include "gp_view_product_node.hh"
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "gp_view_curve_node.hh"
|
||||
#include "gp_version.hh"
|
||||
#include "post_dialog.h"
|
||||
#include "gp_colors.hh"
|
||||
|
||||
// CLASS VARIABLE INITIALIZATION
|
||||
@ -117,25 +116,22 @@ GPViewCurveNode::GPViewCurveNode( Widget Toplevel,
|
||||
"/var/tmp/dpx_gp_curve_XXXXXX", sizeof(curve_data_file_name));
|
||||
|
||||
} else {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Unable to access /tmp or /var/tmp, where a temporary\n"
|
||||
"file (that represents gnuplot curve data) needs\n"
|
||||
"to be created. Please check your permissions.\n");
|
||||
std::cerr << "Unable to access /tmp or /var/tmp, where a temporary\n"
|
||||
<< "file (that represents gnuplot curve data) needs\n"
|
||||
<< "to be created. Please check your permissions." << std::endl ;
|
||||
return;
|
||||
}
|
||||
|
||||
//! Create a name for our temporary data file.
|
||||
if (mkstemp( curve_data_file_name) < 0) {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Unable to generate a temporary file"
|
||||
"name for some mind boggling reason." );
|
||||
std::cerr << "Unable to generate a temporary file"
|
||||
<< "name for some mind boggling reason." << std::endl ;
|
||||
return;
|
||||
}
|
||||
|
||||
//! Open the temporary data file.
|
||||
if ((curve_data_fp = fopen( curve_data_file_name, "w")) == NULL) {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Unable to open a temporary file." );
|
||||
std::cerr << "Unable to open a temporary file." << std::endl ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
extern "C"{
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "gp_view_page_node.hh"
|
||||
#include "gp_version.hh"
|
||||
#include "post_dialog.h"
|
||||
#include "gp_colors.hh"
|
||||
#include "gp_utilities.hh"
|
||||
|
||||
@ -51,10 +50,9 @@ GPViewPageNode::GPViewPageNode(Widget Toplevel, DPC_page* Page, int Xpos, int Yp
|
||||
if ((ncells_s = Page->getAttribute("hcells")) != NULL) {
|
||||
n_hcells = atoi(ncells_s);
|
||||
if ((n_hcells < 0)||(n_hcells > 10)) {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Value for hcells attribute is out of range.\n"
|
||||
"Valid range for hcells is 1 .. 10.\n"
|
||||
"Ignoring hcells value.\n" );
|
||||
std::cerr << "Value for hcells attribute is out of range.\n"
|
||||
<< "Valid range for hcells is 1 .. 10.\n"
|
||||
<< "Ignoring hcells value." << std::endl ;
|
||||
n_hcells = 1;
|
||||
}
|
||||
} else {
|
||||
@ -64,10 +62,9 @@ GPViewPageNode::GPViewPageNode(Widget Toplevel, DPC_page* Page, int Xpos, int Yp
|
||||
if ((ncells_s = Page->getAttribute("vcells")) != NULL) {
|
||||
n_vcells = atoi(ncells_s);
|
||||
if ((n_vcells < 0)||(n_vcells > 10)) {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Value for vcells attribute is out of range.\n"
|
||||
"Valid range for vcells is 1 .. 10.\n"
|
||||
"Ignoring vcells value.\n");
|
||||
std::cerr << "Value for vcells attribute is out of range.\n"
|
||||
<< "Valid range for vcells is 1 .. 10.\n"
|
||||
<< "Ignoring vcells value.\n" << std::endl ;
|
||||
n_vcells = 1;
|
||||
}
|
||||
} else {
|
||||
@ -681,18 +678,16 @@ void GPViewPageNode::finalize() {
|
||||
"/var/tmp/dpx_gp_page_XXXXXX", sizeof(gp_template_file_name));
|
||||
|
||||
} else {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Unable to access /tmp or /var/tmp, where a temporary\n"
|
||||
"file (that represents gnuplot commands) needs\n"
|
||||
"to be created. Please check your permissions.\n");
|
||||
std::cerr << "Unable to access /tmp or /var/tmp, where a temporary\n"
|
||||
<< "file (that represents gnuplot commands) needs\n"
|
||||
<< "to be created. Please check your permissions." << std::endl ;
|
||||
return;
|
||||
}
|
||||
|
||||
//! Create a name for our temporary gnuplot command file.
|
||||
if (mkstemp( gp_template_file_name) < 0) {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Unable to generate a temporary file"
|
||||
"name for some mind boggling reason." );
|
||||
std::cerr << "Unable to generate a temporary file"
|
||||
<< "name for some mind boggling reason." << std::endl ;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -817,18 +812,16 @@ void GPViewPageNode::finalize() {
|
||||
"/var/tmp/dpx_gxplot_XXXXXX", sizeof(outFileName));
|
||||
|
||||
} else {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Unable to access /tmp or /var/tmp, where a temporary\n"
|
||||
"file for printing needs to be created.\n"
|
||||
"Please check your permissions.\n");
|
||||
std::cerr << "Unable to access /tmp or /var/tmp, where a temporary\n"
|
||||
<< "file for printing needs to be created.\n"
|
||||
<< "Please check your permissions." << std::endl ;
|
||||
return;
|
||||
}
|
||||
|
||||
//! Create a name for our temporary gnuplot command file.
|
||||
if (mkstemp(outFileName) < 0) {
|
||||
post_dialog( toplevel, XmDIALOG_ERROR,
|
||||
"Unable to generate a temporary file"
|
||||
"name for some mind boggling reason." );
|
||||
std::cerr << "Unable to generate a temporary file"
|
||||
<< "name for some mind boggling reason." << std::endl ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ GPViewProductNode::~GPViewProductNode() {
|
||||
#endif
|
||||
|
||||
GPViewPageNode *page_view_node;
|
||||
TableViewNode *table_view_node;
|
||||
int n,i;
|
||||
|
||||
n = (int)page_node_list.size();
|
||||
@ -26,10 +25,4 @@ GPViewProductNode::~GPViewProductNode() {
|
||||
if (page_view_node) { delete page_view_node; }
|
||||
}
|
||||
|
||||
|
||||
n = (int)table_node_list.size();
|
||||
for (i=0 ; i<n ; i++ ) {
|
||||
table_view_node = table_node_list[i];
|
||||
if (table_view_node) { delete table_view_node; }
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <vector>
|
||||
#include "DPC/DPC_product.hh"
|
||||
#include "gp_view_page_node.hh"
|
||||
#include "table_view_node.hh"
|
||||
|
||||
/**
|
||||
* This class represents a Trick Data Product.
|
||||
@ -17,7 +16,6 @@ public:
|
||||
DPC_product *product;
|
||||
Widget toplevel;
|
||||
std::vector <GPViewPageNode *> page_node_list;
|
||||
std::vector <TableViewNode*> table_node_list;
|
||||
|
||||
GPViewProductNode(Widget Toplevel, DPC_product* Product);
|
||||
|
||||
|
@ -4,17 +4,6 @@
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#include <Xm/MainW.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/List.h>
|
||||
#include <Xm/CascadeB.h>
|
||||
#include <Xm/PushBG.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/LabelG.h>
|
||||
#include <Xm/ScrolledW.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/Protocols.h>
|
||||
|
||||
#include "DPC/DPC_product.hh"
|
||||
#include "DPM/DPM_parse_tree.hh"
|
||||
#include "DPM/DPM_session.hh"
|
||||
|
@ -23,9 +23,9 @@ endif
|
||||
ifeq ($(TRICK_HOST_TYPE), Darwin)
|
||||
INCDIRS += -I/usr/X11/include
|
||||
MOTIF_INCDIR = -I/sw/include
|
||||
XLIBS = -L/sw/lib -lXm -L/usr/X11R6/lib -lXt -lX11 ${LIBXML} -lc++abi
|
||||
XLIBS = -L/usr/X11R6/lib -lXt -lX11 ${LIBXML} -lc++abi
|
||||
else
|
||||
XLIBS = -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lXm -lXt -lX11 ${LIBXML}
|
||||
XLIBS = -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lXt -lX11 ${LIBXML}
|
||||
endif
|
||||
|
||||
ifneq ($(HDF5),)
|
||||
@ -46,8 +46,7 @@ ALL_LIBS = $(CONTROLLER_LIBS) $(MODEL_LIBS) ${DP_LIBS} ${TRICK_UNIT_LIBS} ${HDF5
|
||||
## MODEL TARGETS ##
|
||||
#############################################################################
|
||||
|
||||
C_OBJECT_FILES = $(OBJDIR)/parse_format.o \
|
||||
$(OBJDIR)/post_dialog.o
|
||||
C_OBJECT_FILES = $(OBJDIR)/parse_format.o
|
||||
|
||||
CXX_OBJECT_FILES = $(OBJDIR)/gp_view.o \
|
||||
$(OBJDIR)/gp_colors.o \
|
||||
@ -56,7 +55,6 @@ CXX_OBJECT_FILES = $(OBJDIR)/gp_view.o \
|
||||
$(OBJDIR)/gxplot.o \
|
||||
$(OBJDIR)/gp_view_curve_node.o \
|
||||
$(OBJDIR)/gp_view_plot_node.o \
|
||||
$(OBJDIR)/table_view_node.o \
|
||||
$(OBJDIR)/gp_view_page_node.o \
|
||||
$(OBJDIR)/gp_view_product_node.o
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
|
||||
#include "post_dialog.h"
|
||||
|
||||
static void DestroyWidget_cb( Widget w, XtPointer client_data, XtPointer call_data) {
|
||||
XtDestroyWidget(w);
|
||||
}
|
||||
|
||||
Widget post_dialog( Widget parent, int dialog_type, const char * msg) {
|
||||
|
||||
Widget dialog;
|
||||
XmString text;
|
||||
|
||||
dialog = XmCreateMessageDialog( parent, "dialog", NULL, 0);
|
||||
text = XmStringCreateLocalized((char *)msg);
|
||||
XtVaSetValues( dialog,
|
||||
XmNdialogType, dialog_type,
|
||||
XmNmessageString, text,
|
||||
NULL);
|
||||
XmStringFree( text);
|
||||
|
||||
// Remove the Cancel Button from the dialog.
|
||||
XtUnmanageChild( XmMessageBoxGetChild( dialog, XmDIALOG_CANCEL_BUTTON));
|
||||
|
||||
// Grey out the Help Button
|
||||
XtSetSensitive( XmMessageBoxGetChild( dialog, XmDIALOG_HELP_BUTTON), False);
|
||||
|
||||
// Destroy the widget when the user clicks OK.
|
||||
XtAddCallback( dialog, XmNokCallback, DestroyWidget_cb, (XtPointer)NULL);
|
||||
|
||||
XtManageChild( dialog);
|
||||
|
||||
return dialog;
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
|
||||
#ifndef POST_DIALOG_H
|
||||
#define POST_DIALOG_H
|
||||
|
||||
#include <Xm/MessageB.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Post an X-Windows Dialog box with the given message.
|
||||
* @param parent - parent Widget for the dialog.
|
||||
* @param dialog_type - of type XmNdialogType
|
||||
* Possible values are:
|
||||
* - XmDIALOG_ERROR
|
||||
* - XmDIALOG_INFORMATION
|
||||
* - XmDIALOG_MESSAGE
|
||||
* - XmDIALOG_QUESTION
|
||||
* - XmDIALOG_TEMPLATE
|
||||
* - XmDIALOG_WARNING
|
||||
* - XmDIALOG_WORKING
|
||||
* @param msg - message string to be displayed on the dialog.
|
||||
*/
|
||||
Widget post_dialog( Widget parent, int dialog_type, const char * msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,400 +0,0 @@
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/LabelG.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/FileSB.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <stdio.h> // for snprintf
|
||||
#include <string.h> // for strcpy, strlen, strdup
|
||||
#include <libgen.h> // for dirname, basename
|
||||
#include <unistd.h> // for access
|
||||
#include <fcntl.h> // for open, write, close
|
||||
|
||||
#define exists(filename) (!access(filename, F_OK))
|
||||
|
||||
#include "table_view_node.hh"
|
||||
#include "parse_format.h"
|
||||
#include "post_dialog.h"
|
||||
|
||||
#define BYTES_PER_MALLOC 0xFFFF
|
||||
|
||||
// CALLBACK
|
||||
static void FSB_cb( Widget w, XtPointer client_data, XtPointer call_data) {
|
||||
|
||||
char *filename;
|
||||
XmFileSelectionBoxCallbackStruct *cbs =
|
||||
(XmFileSelectionBoxCallbackStruct *) call_data;
|
||||
|
||||
TableViewNode* table_view_node = (TableViewNode *)client_data;
|
||||
|
||||
if (cbs->reason == XmCR_OK) {
|
||||
|
||||
// Get the filename
|
||||
if (!XmStringGetLtoR (cbs->value, XmFONTLIST_DEFAULT_TAG, &filename))
|
||||
return;
|
||||
|
||||
if (!*filename) {
|
||||
post_dialog( table_view_node->toplevel, XmDIALOG_ERROR, "No file selected.");
|
||||
} else if (exists (filename)) {
|
||||
post_dialog( table_view_node->toplevel, XmDIALOG_ERROR, "File already exists.");
|
||||
} else {
|
||||
int fd;
|
||||
if ((fd = creat(filename, 0660)) < 0 ) {
|
||||
post_dialog( table_view_node->toplevel, XmDIALOG_ERROR, "Error occured attempting to create file.");
|
||||
} else {
|
||||
write(fd, table_view_node->table_text_buf, table_view_node->table_buf_size );
|
||||
close(fd);
|
||||
XtDestroyWidget(w);
|
||||
}
|
||||
}
|
||||
XtFree( filename);
|
||||
|
||||
} else {
|
||||
XtDestroyWidget(w);
|
||||
}
|
||||
}
|
||||
|
||||
// CALLBACK
|
||||
static void save_table_cb( Widget w, XtPointer client_data, XtPointer call_data) {
|
||||
|
||||
Widget dialog;
|
||||
|
||||
TableViewNode* table_view_node = (TableViewNode *)client_data;
|
||||
|
||||
dialog = XmCreateFileSelectionDialog(table_view_node->toplevel, (char *)"filesb", NULL, 0 );
|
||||
XtAddCallback ( dialog, XmNokCallback, FSB_cb , (XtPointer)table_view_node);
|
||||
XtAddCallback ( dialog, XmNcancelCallback, FSB_cb , (XtPointer)table_view_node);
|
||||
|
||||
XtManageChild( dialog);
|
||||
|
||||
}
|
||||
|
||||
static char* twprint( char* text_buf, size_t *text_buf_size, size_t *insertion_pos, char* format, ...) {
|
||||
char message[4096];
|
||||
va_list vargs;
|
||||
size_t new_insertion_pos;
|
||||
size_t message_len;
|
||||
|
||||
va_start(vargs, format);
|
||||
vsprintf(message, format, vargs); // vsnprint ??
|
||||
va_end(vargs);
|
||||
|
||||
message_len = strlen(message);
|
||||
new_insertion_pos = *insertion_pos + message_len;
|
||||
|
||||
if (text_buf == NULL) {
|
||||
text_buf = (char*)calloc(1, size_t(BYTES_PER_MALLOC));
|
||||
}
|
||||
|
||||
while ( new_insertion_pos > *text_buf_size) {
|
||||
*text_buf_size += (size_t)BYTES_PER_MALLOC;
|
||||
if ((text_buf = (char *)realloc( text_buf, *text_buf_size )) == NULL) {
|
||||
cerr << "OUT_OF_MEMORY in twprint." << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(&text_buf[*insertion_pos], message);
|
||||
*insertion_pos = new_insertion_pos;
|
||||
|
||||
return (text_buf);
|
||||
}
|
||||
|
||||
// CLASS VARIABLE INITIALIZATION
|
||||
int TableViewNode::instance_count = 0;
|
||||
|
||||
// CONSTRUCTOR
|
||||
TableViewNode::TableViewNode( Widget Toplevel, DPC_table* Table, int Xpos, int Ypos, int Width, int Height) {
|
||||
|
||||
Arg wargs[50];
|
||||
int nargs;
|
||||
|
||||
int n_columns;
|
||||
int colix;
|
||||
double *row_values;
|
||||
char **column_heading_format;
|
||||
char **column_data_format;
|
||||
int *column_width;
|
||||
int total_column_width;
|
||||
char *heading_line_string;
|
||||
double time;
|
||||
|
||||
const char * foreground_color;
|
||||
const char * background_color;
|
||||
Pixel fg,bg;
|
||||
Pixmap pixmap;
|
||||
|
||||
const char *table_title;
|
||||
const char *run_dir;
|
||||
|
||||
char charbuf[256];
|
||||
char default_table_title[256];
|
||||
|
||||
table = Table;
|
||||
toplevel = Toplevel;
|
||||
|
||||
table_text_buf = NULL;
|
||||
table_insertion_pos = 0;
|
||||
table_buf_size = 0;
|
||||
|
||||
// -----------------------------
|
||||
// Create the table widget name.
|
||||
// -----------------------------
|
||||
|
||||
snprintf( charbuf, sizeof(charbuf), "Table_Dialog_%d", instance_count);
|
||||
|
||||
// ---------------------------
|
||||
//
|
||||
// ---------------------------
|
||||
if ((table_title = table->getTitle()) == NULL ) {
|
||||
snprintf( default_table_title, sizeof(default_table_title), "Table %d", instance_count);
|
||||
table_title = default_table_title;
|
||||
}
|
||||
|
||||
//title = strdup(table_title);
|
||||
run_dir = table->getRunDir();
|
||||
|
||||
// --------------------------------------
|
||||
// Create the dialog shell for this page.
|
||||
// --------------------------------------
|
||||
nargs = 0;
|
||||
XtSetArg( wargs[nargs], XmNtitle, table_title ); nargs++;
|
||||
XtSetArg( wargs[nargs], XmNx, 100 ); nargs++;
|
||||
XtSetArg( wargs[nargs], XmNy, 100 ); nargs++;
|
||||
|
||||
dialog_shell_widget = XmCreateDialogShell( toplevel, charbuf, wargs, nargs);
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Create the form manager widget for this table whose parent is the dialog shell.
|
||||
// ---------------------------------------------------------------------------------
|
||||
snprintf( charbuf, sizeof(charbuf), "FormForTable%d", instance_count);
|
||||
|
||||
main_form_widget =
|
||||
XtVaCreateWidget( charbuf,
|
||||
xmFormWidgetClass, dialog_shell_widget,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues (main_form_widget, XmNforeground, &fg, XmNbackground, &bg, NULL);
|
||||
|
||||
// -------------------------------------------------------
|
||||
// Ctrls form
|
||||
// -------------------------------------------------------
|
||||
|
||||
ctrls_form_widget = XtVaCreateManagedWidget( "CtrlsForm", xmFormWidgetClass, main_form_widget,
|
||||
XmNresizePolicy, XmRESIZE_GROW,
|
||||
XmNfractionBase, 10,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_NONE,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues (ctrls_form_widget, XmNforeground, &fg, XmNbackground, &bg, NULL);
|
||||
|
||||
|
||||
save_button_widget = XtVaCreateManagedWidget( "Save", xmPushButtonWidgetClass, ctrls_form_widget,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
XtAddCallback( save_button_widget, XmNactivateCallback, save_table_cb, (XtPointer)this);
|
||||
|
||||
|
||||
pixmap = XmGetPixmap( XtScreen(toplevel), (char *)"trick_small.xpm", fg, bg);
|
||||
if (pixmap == XmUNSPECIFIED_PIXMAP) {
|
||||
trick_label = XtVaCreateManagedWidget( "Trick", xmLabelGadgetClass, ctrls_form_widget,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
} else {
|
||||
trick_label = XtVaCreateManagedWidget( "Trick", xmLabelGadgetClass, ctrls_form_widget,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNlabelType, XmPIXMAP,
|
||||
XmNlabelPixmap, pixmap,
|
||||
NULL);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
// Text Widget
|
||||
// -------------------------------------------------------
|
||||
nargs = 0;
|
||||
XtSetArg( wargs[nargs], XmNeditable, False ); nargs++;
|
||||
XtSetArg( wargs[nargs], XmNeditMode, XmMULTI_LINE_EDIT); nargs++;
|
||||
XtSetArg( wargs[nargs], XmNcursorPositionVisible, False); nargs++;
|
||||
|
||||
text_widget = XmCreateScrolledText(main_form_widget, (char *)"scrolledtext", wargs, nargs);
|
||||
|
||||
XtVaSetValues( XtParent(text_widget),
|
||||
XmNwidth, 500,
|
||||
XmNheight, 400,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, ctrls_form_widget,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
XtManageChild (text_widget);
|
||||
XtManageChild (main_form_widget);
|
||||
|
||||
|
||||
// -------------------------------------------------------
|
||||
// Set the table's foreground color.
|
||||
// -------------------------------------------------------
|
||||
//XtVaSetValues( text_widget, XmNforeground, BlackPixel(XtDisplay(toplevel),0), NULL);
|
||||
if ((foreground_color = table->getAttribute("foreground_color")) != NULL) {
|
||||
XColor color_def;
|
||||
if ( XParseColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), foreground_color, &color_def )) {
|
||||
if ( XAllocColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), &color_def )) {
|
||||
XtVaSetValues( text_widget, XmNforeground, color_def.pixel, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
// Set the table's background color.
|
||||
// -------------------------------------------------------
|
||||
//XtVaSetValues( text_widget, XmNbackground, BlackPixel(XtDisplay(toplevel),0), NULL);
|
||||
if ((background_color = table->getAttribute("background_color")) != NULL) {
|
||||
XColor color_def;
|
||||
if ( XParseColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), background_color, &color_def )) {
|
||||
if ( XAllocColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), &color_def )) {
|
||||
XtVaSetValues( text_widget, XmNbackground, color_def.pixel, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos,
|
||||
(char *)"Title: %s\n", table_title);
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos,
|
||||
(char *)"Run: %s\n", run_dir);
|
||||
|
||||
n_columns = table->getNumColumns();
|
||||
|
||||
column_heading_format = (char **)calloc( (size_t)n_columns, sizeof(char*));
|
||||
column_data_format = (char **)calloc( (size_t)n_columns, sizeof(char*));
|
||||
column_width = (int *)calloc( (size_t)n_columns, sizeof(int));
|
||||
total_column_width = 0;
|
||||
|
||||
for (colix=0; colix < n_columns ; colix++) {
|
||||
int sign, width, precision, conv_char;
|
||||
const char *user_format = table->getColumnAttribute( colix,"format");
|
||||
|
||||
// Determine whether the print format string that the user specified
|
||||
// is valid. If it is, we need the width that was specified in the format
|
||||
// so that we can use it for the column headings. If the user specified
|
||||
// format is invalid, then we must use a default.
|
||||
|
||||
if ( parse_format_string(user_format, &sign, &width, &precision, &conv_char) < 0 ) {
|
||||
// User supplied format failed to parse, so use the default.
|
||||
column_heading_format[colix] = (char *)"%+18s";
|
||||
column_data_format[colix] = strdup("%18.6e");
|
||||
column_width[colix] = 18;
|
||||
} else {
|
||||
// Parse succeeded.
|
||||
char temp_s[32];
|
||||
sprintf(temp_s,"%%+%ds",width);
|
||||
column_heading_format[colix] = strdup(temp_s);
|
||||
column_data_format[colix] = strdup(user_format);
|
||||
column_width[colix] = width;
|
||||
}
|
||||
total_column_width += column_width[colix];
|
||||
}
|
||||
|
||||
heading_line_string = (char *)calloc( (size_t)total_column_width+1, sizeof(char));
|
||||
memset(heading_line_string,'-',total_column_width);
|
||||
|
||||
// Print a line of dashes over the column headings.
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, (char *)"%s\n", heading_line_string);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Print out the column heading labels.
|
||||
// ----------------------------------------------------------------
|
||||
for (colix=0; colix < n_columns ; colix++) {
|
||||
const char *column_label = table->getColumnLabel( colix);
|
||||
|
||||
if (!column_label) {
|
||||
snprintf( charbuf, sizeof(charbuf), "Column_%d", colix);
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos,
|
||||
column_heading_format[colix], charbuf);
|
||||
} else {
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos,
|
||||
column_heading_format[colix], column_label);
|
||||
}
|
||||
}
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, (char *)"\n");
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Print out the column heading units
|
||||
// ----------------------------------------------------------------
|
||||
for (colix=0; colix < n_columns ; colix++) {
|
||||
const char *col_units = table->getColumnUnits( colix);
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos,
|
||||
column_heading_format[colix], col_units);
|
||||
}
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, (char *)"\n");
|
||||
|
||||
// Print a line of dashes under the column headings.
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, (char *)"%s\n", heading_line_string);
|
||||
|
||||
free(heading_line_string);
|
||||
// ----------------------------------------------------------------
|
||||
// ----------------------------------------------------------------
|
||||
row_values = new double[n_columns];
|
||||
|
||||
while (table->getRow(&time, row_values)) {
|
||||
|
||||
for (colix=0; colix < n_columns ; colix++) {
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos,
|
||||
column_data_format[colix], row_values[colix]);
|
||||
}
|
||||
table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, (char *)"\n");
|
||||
}
|
||||
|
||||
// Free all the column building arrays.
|
||||
free( column_heading_format);
|
||||
free( column_data_format);
|
||||
free( column_width);
|
||||
|
||||
XtVaSetValues( text_widget, XmNvalue, table_text_buf, NULL);
|
||||
|
||||
XtVaSetValues(dialog_shell_widget,
|
||||
XmNx, Xpos,
|
||||
XmNy, Ypos,
|
||||
XmNwidth, Width,
|
||||
XmNheight, Height,
|
||||
NULL);
|
||||
|
||||
instance_count ++;
|
||||
}
|
||||
|
||||
//DESTRUCTOR
|
||||
TableViewNode::~TableViewNode() {
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "TableViewNode DESTRUCTOR." << endl;
|
||||
#endif
|
||||
|
||||
if (table_text_buf != NULL) {
|
||||
free(table_text_buf);
|
||||
}
|
||||
// FIXME: figure out how to destroy text_widget without
|
||||
// getting warning messages.
|
||||
// XtDestroyWidget(text_widget);
|
||||
|
||||
XtDestroyWidget(trick_label);
|
||||
XtDestroyWidget(save_button_widget);
|
||||
XtDestroyWidget(ctrls_form_widget);
|
||||
XtDestroyWidget(main_form_widget);
|
||||
XtDestroyWidget(dialog_shell_widget);
|
||||
}
|
||||
|
||||
void TableViewNode::finalize() {
|
||||
|
||||
XtManageChild( main_form_widget);
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
|
||||
#ifndef TABLE_VIEW_NODE_HH
|
||||
#define TABLE_VIEW_NODE_HH
|
||||
|
||||
#include "DPC/DPC_table.hh"
|
||||
|
||||
extern "C"{
|
||||
#include <X11/Intrinsic.h>
|
||||
}
|
||||
|
||||
/**
|
||||
* This class represents an X-Windows based Table for Trick Data Products.
|
||||
* @author John M. Penn
|
||||
*/
|
||||
class TableViewNode {
|
||||
public:
|
||||
DPC_table* table; /**< The source of this table's data. */
|
||||
Widget toplevel; /**< This is the toplevel X-application
|
||||
Widget. */
|
||||
Widget dialog_shell_widget; /**< This is the DialogShell (the window) for
|
||||
the Table. */
|
||||
Widget main_form_widget; /**< This is the main Form for the table. */
|
||||
Widget ctrls_form_widget; /**< This is the form on which the SAVE
|
||||
button and the Trick logo is placed. */
|
||||
Widget save_button_widget; /**< This is the save-button Widget. */
|
||||
Widget trick_label; /**< This is the label Widget that displays the
|
||||
Trick logo. */
|
||||
Widget text_widget; /**< This is the ScrolledText Widget that
|
||||
contains the printed table text. */
|
||||
char * table_text_buf; /**< This is a pointer to the text buffer
|
||||
for the table. It is allocated and
|
||||
realloced as needed by twprint(). When all
|
||||
of the printing is done, it is used to
|
||||
set the text of the text_widget. */
|
||||
size_t table_insertion_pos; /**< This is an index into table_text_buf where
|
||||
more text should be added by twprint(). */
|
||||
size_t table_buf_size; /**< The size (in bytes) of the buffer
|
||||
referenced by table_text_buf. */
|
||||
|
||||
/**
|
||||
* TableViewNode constructor.
|
||||
* @param Toplevel - the toplevel X-application Widget.
|
||||
* @param Table - the DPC_table object from which we get all of the data to
|
||||
* create the X-window based table.
|
||||
* @param Xpos - The X coordinate of the upper left hand corner of the table's
|
||||
* X-window.
|
||||
* @param Ypos - The Y coordinate of the upper left hand corner of the table's
|
||||
* X-window.
|
||||
* @param Width - The width of the of the table's X-window.
|
||||
* @param Height - The height of the of the table's X-window.
|
||||
*/
|
||||
TableViewNode( Widget Toplevel,
|
||||
DPC_table* Table,
|
||||
int Xpos, int Ypos, int Width, int Height);
|
||||
|
||||
/**
|
||||
* TableViewNode destructor.
|
||||
*/
|
||||
~TableViewNode();
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*/
|
||||
void finalize();
|
||||
|
||||
private:
|
||||
static int instance_count;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user