static void configure_plot(PlotWindowInfo *plot) { if (plot->plotter == 0) return; int ndim = plot->plotter->dimensions(); // Set up plot menu int i; for (i = 0; plot_menu[i].name != 0; i++) { if ((plot_menu[i].type & MMTypeMask) != MMToggle) continue; string name = plot_menu[i].name; const string s1 = "*" + name; Widget w = XtNameToWidget(plot->shell, s1.chars()); if (name.contains("2d", -1)) XtSetSensitive(w, ndim == 2); else if (name.contains("3d", -1)) XtSetSensitive(w, ndim >= 3); else XtSetSensitive(w, ndim >= 2); } // Log scale is available only iff all values are non-negative Widget logscale = XtNameToWidget(plot->shell, "*logscale"); XtSetSensitive(logscale, plot->plotter->min_v() >= 0.0); // Axes can be toggled in 2d mode only Widget xzeroaxis = XtNameToWidget(plot->shell, "*xzeroaxis"); Widget yzeroaxis = XtNameToWidget(plot->shell, "*yzeroaxis"); XtSetSensitive(xzeroaxis, ndim <= 2); XtSetSensitive(yzeroaxis, ndim <= 2); // Z Tics are available in 3d mode only Widget ztics = XtNameToWidget(plot->shell, "*ztics"); XtSetSensitive(ztics, ndim >= 3); // Contour drawing is available in 3d mode only Widget base = XtNameToWidget(plot->shell, "*base"); Widget surface = XtNameToWidget(plot->shell, "*surface"); XtSetSensitive(base, ndim >= 3); XtSetSensitive(surface, ndim >= 3); // Set scrollbars manage_child(plot->hsb, ndim >= 3); manage_child(plot->vsb, ndim >= 3); // Check if we can export something bool have_source = false; bool can_export = false; const StringArray& sources = plot->plotter->data_files(); for (i = 0; i < sources.size(); i++) { if (!sources[i].empty()) { if (have_source) can_export = false; // Multiple source files else can_export = have_source = true; } } Widget export_w = XtNameToWidget(plot->shell, "*export"); set_sensitive(export_w, can_export); // The remainder requires settings if (plot->settings.empty()) { // No settings yet if (plot->settings_timer == 0) { plot->settings_delay = new StatusDelay("Retrieving Plot Settings"); // Save settings... plot->settings_file = tempfile(); string cmd = "save " + quote(plot->settings_file) + "\n"; send(plot, cmd); // ...and try again in 250ms plot->settings_timer = XtAppAddTimeOut(XtWidgetToApplicationContext(plot->shell), 250, GetPlotSettingsCB, XtPointer(plot)); // Set initial scrollbar defaults XtVaSetValues(plot->vsb, XmNvalue, 60, XtPointer(0)); XtVaSetValues(plot->hsb, XmNvalue, 30, XtPointer(0)); } return; } configure_options(plot, view_menu, plot->settings); configure_options(plot, contour_menu, plot->settings); configure_options(plot, scale_menu, plot->settings); // Get style for (i = 0; plot_menu[i].name != 0; i++) { if ((plot_menu[i].type & MMTypeMask) != MMToggle) continue; string name = plot_menu[i].name; const string s1 = "*" + name; Widget w = XtNameToWidget(plot->shell, s1.chars()); bool set = plot->settings.contains("\nset data style " + name + "\n"); XmToggleButtonSetState(w, set, False); } // Get position int rot_x = 60; int rot_z = 30; int view_index = plot->settings.index("set view "); if (view_index >= 0) { // `set view <rot_x> {,{<rot_z>}{,{<scale>}{,<scale_z>}}}' string view_setting = plot->settings.after("set view "); rot_x = atoi(view_setting.chars()); view_setting = view_setting.after(", "); rot_z = atoi(view_setting.chars()); } XtVaSetValues(plot->vsb, XmNvalue, rot_x, XtPointer(0)); XtVaSetValues(plot->hsb, XmNvalue, rot_z, XtPointer(0)); }
int main(int argc, char** argv){ signal(SIGTERM, term); signal(SIGINT, term); configure_options(argc, argv); perf_mon = camio_perf_init("blob:debug.perf", 256 * 1024); if (options.format != "hex" && options.format != "ascii" && options.format != "bin") { printf("ERROR: invalid output format for name specified; must be one of " "'ascii', 'bin', 'hex'!\n"); exit(1); } tcp_endpoint = camio_iostream_delimiter_new( camio_iostream_new(options.remote, NULL, NULL, NULL), delimit, NULL); //out = camio_ostream_new(options.output, NULL, NULL, perf_mon); printf("Writing name to %s (%p)\n", options.output, out); // First generate a random name for this object dios_name_t name; char str_name[65]; generate_guid_name(&name, &str_name[0]); printf("Name: %s\n", str_name); // Manufacture an object creation message Firmament__BaseMessage bm = FIRMAMENT__BASE_MESSAGE__INIT; Firmament__CreateRequest create_req = FIRMAMENT__CREATE_REQUEST__INIT; Firmament__ReferenceDescriptor rd = FIRMAMENT__REFERENCE_DESCRIPTOR__INIT; bm.create_request = &create_req; bm.create_request->reference = &rd; rd.type = FIRMAMENT__REFERENCE_DESCRIPTOR__REFERENCE_TYPE__CONCRETE; rd.location = options.path; // Set up reference descriptor rd.id.len = sizeof(dios_name_t); rd.id.data = name.raw; // Pack and send! send_coord_base_msg(&bm); // Check if we receive an ACK uint8_t* resp_buff; uint64_t len = tcp_endpoint->start_read(tcp_endpoint, &resp_buff); decapsulate_envelope(&resp_buff, &len); Firmament__BaseMessage* base_msg = NULL; base_msg = firmament__base_message__unpack(NULL, len, resp_buff); if (!base_msg->create_response) { printf("ERROR: received a response message that did not contained a " "CreateResponse field!\n"); exit(1); } else { if (base_msg->create_response->success) { printf("Data object uploaded SUCCESSFULLY!\n"); } else { printf("Upload of data object FAILED, try again!\n"); exit(1); } } // Write the name to the requested output stream // TODO(malte) // Clean up and quit term(0); }