// barChartDriver.C /* $Log: barChartDriver.C,v $ /* Revision 1.13 1996/01/11 01:52:53 tamches /* added command long2shortFocusName /* * Revision 1.12 1996/01/10 02:25:34 tamches * added --xsynch and --debug command-line options * installed getMetricColorNameCommand * * Revision 1.11 1995/12/20 18:37:59 newhall * matherr.h does not need to be included by visis * * Revision 1.10 1995/11/29 00:39:48 tamches * now include tkTools.h, pdLogo.h * Now hardcode the pdLogo * * Revision 1.9 1995/11/08 21:17:12 naim * Adding matherr exception handler function to avoid error message when * computing the "not a number" (NaN) value - naim * * Revision 1.8 1995/11/08 02:17:06 tamches * minor cleanups * * Revision 1.7 1995/09/22 19:25:04 tamches * removed warnings under g++ 2.7.0 * * Revision 1.6 1995/08/06 22:11:13 tamches * barChart now uses tcl2c. * Now needs no command-line args. * * Revision 1.5 1995/07/06 18:55:31 tamches * Now contains a main program suitable for tk4.0 * * Revision 1.4 1994/10/13 00:52:36 tamches * Minor additions to support a new command related to sorting * of resources * * Revision 1.3 1994/10/10 23:08:43 tamches * preliminary changes on the way to swapping the x and y axes * * Revision 1.2 1994/09/29 20:05:36 tamches * minor cvs fixes * * Revision 1.1 1994/09/29 19:50:51 tamches * initial implementation. * entrypoint for barchart C++ program. we create new tcl * commands (which will eventually call back to barChartTcl.C * and from there barChart.C) and then launch barChart.tcl. * */ #include #include #include #include "tcl.h" #include "tk.h" #include "tkTools.h" #include "pdLogo.h" #include "paradyn/xbm/logo.xbm" #include "dg2.h" #include "barChartTcl.h" void panic(const char *msg) { cerr << msg << endl; exit(5); } Tcl_Interp *MainInterp = NULL; // needed by Dg bool xsynchFlag = false; int main(int argc, char **argv) { // Loop through the arguments: for (argc--, argv++; argc > 0; argc--, argv++) { if (0==strcmp(*argv, "--xsynch")) xsynchFlag = true; else if (0==strcmp(*argv, "--debug")) { xsynchFlag = true; cout << "barChart pid " << getpid() << " at sigpause..." << endl; sigpause(0); } else { cerr << "barChart: unrecognized argument \"" << *argv << "\"" << endl; return 5; } } // barChart no longer requires any arguments, thanks to tcl2c. if (argc == 2) panic("barChart: argc should be 1"); MainInterp = Tcl_CreateInterp(); assert(MainInterp); Tk_Window mainTkWindow = Tk_CreateMainWindow(MainInterp, NULL, "barChart", "BarChart"); if (mainTkWindow == NULL) tclpanic(MainInterp, "Could not Tk_CreateMainWindow()"); if (TCL_OK != Tcl_Init(MainInterp)) tclpanic(MainInterp, "Could not Tcl_Init()"); if (TCL_OK != Tk_Init(MainInterp)) tclpanic(MainInterp, "Could not Tk_Init"); if (TCL_OK != Dg2_Init(MainInterp)) tclpanic(MainInterp, "Could not Dg2_Init()"); Tcl_SetVar(MainInterp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); // Install our new tcl commands Tcl_CreateCommand(MainInterp, "resizeCallback", resizeCallbackCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "exposeCallback", exposeCallbackCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "resourcesAxisHasChanged", resourcesAxisHasChangedCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "metricsAxisHasChanged", metricsAxisHasChangedCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "newScrollPosition", newScrollPositionCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "dataFormatHasChanged", dataFormatHasChangedCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "rethinkIndirectResourcesCallback", rethinkIndirectResourcesCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "getMetricColorName", getMetricColorNameCommand, NULL, // ClientData deleteDummyProc); Tcl_CreateCommand(MainInterp, "long2shortFocusName", long2shortFocusNameCommand, NULL, // ClientData deleteLaunchBarChartCommand); Tcl_CreateCommand(MainInterp, "launchBarChart", launchBarChartCommand, NULL, // ClientData deleteLaunchBarChartCommand); // Krishna's tcl2c stuff gets loaded here: // (initialize_tcl_sources() was auto-generated by 'tcl2c') extern int initialize_tcl_sources(Tcl_Interp *); if (TCL_OK != initialize_tcl_sources(MainInterp)) tclpanic(MainInterp, "barChart: could not initialize_tcl_sources"); //if (TCL_OK != Tcl_EvalFile(MainInterp, "/p/paradyn/development/tamches/core/visiClients/barchart/barChart.tcl")) // tclpanic(MainInterp, "could not source barChart.tcl manually"); pdLogo::install_fixed_logo("paradynLogo", logo_bits, logo_width, logo_height); tcl_cmd_installer createPdLogo(MainInterp, "makeLogo", pdLogo::makeLogoCommand, (ClientData)mainTkWindow); myTclEval(MainInterp, "init_barchart_window"); myTclEval(MainInterp, "Initialize"); Tk_MainLoop(); // returns when all tk windows are closed // shouldn't we be doing some cleanup here? }