Esempio n. 1
0
/* ARGSUSED */
void create_nonl_frame(Widget, XtPointer, XtPointer)
{
    int i;
    int x, y;
    Widget sw, fr, rc, rc1, rc2, lab, but1[3];
    set_wait_cursor();
    if (nonl_frame == NULL)
    {
        char *label1[3];
        /*
         label1[0] = "Accept";
         label1[1] = "Eval...";
         label1[2] = "Close";
      */
        label1[0] = (char *)"Accept";
        label1[1] = (char *)"Close";
        XmGetPos(app_shell, 0, &x, &y);
        nonl_frame = XmCreateDialogShell(app_shell, (char *)"Non-linear curve fitting", NULL, 0);
        handle_close(nonl_frame);
        XtVaSetValues(nonl_frame, XmNx, x, XmNy, y, NULL);
        nonl_panel = XmCreateForm(nonl_frame, (char *)"nonl_frame_rc", NULL, 0);
        fr = XmCreateFrame(nonl_panel, (char *)"nonl_frame", NULL, 0);
        rc = XmCreateRowColumn(fr, (char *)"nonl_rc", NULL, 0);

        nonl_set_item = CreateSetChoice(rc, (char *)"Use set:", maxplot, 0);

        nonl_load_item = CreatePanelChoice(rc,
                                           "Load:",
                                           4,
                                           "Fitted values",
                                           "Residuals",
                                           "None",
                                           NULL, NULL);

        nonl_loadgraph_item = CreateGraphChoice(rc, (char *)"To graph:", maxgraph, 0);

        nonl_formula_item = (Widget)CreateTextItem2(rc, 35, (char *)"Function:");
        xv_setstr(nonl_formula_item, (char *)"y = ");

        nonl_nparm_item = CreateTextItem2(rc, 5, (char *)"# of parameters:");
        nonl_tol_item = CreateTextItem2(rc, 10, (char *)"Tolerance:");
        XtManageChild(rc);
        XtManageChild(fr);
        sw = XtVaCreateManagedWidget("sw",
                                     xmScrolledWindowWidgetClass, nonl_panel,
                                     XmNscrollingPolicy, XmAUTOMATIC,
                                     NULL);

        rc = XmCreateRowColumn(sw, (char *)"rc", NULL, 0);
        XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);

        rc1 = XmCreateRowColumn(rc, (char *)"rc1", NULL, 0);
        lab = XmCreateLabel(rc1, (char *)"Initial guess:", NULL, 0);
        XtManageChild(lab);
        rc2 = XmCreateRowColumn(rc, (char *)"rc2", NULL, 0);
        lab = XmCreateLabel(rc2, (char *)"Computed values:", NULL, 0);
        XtManageChild(lab);

        for (i = 0; i < MAXPARM; i++)
        {
            sprintf(buf, "A%1d: ", i);
            nonl_initial_item[i] = CreateTextItem2(rc1, 15, buf);
        }
        for (i = 0; i < MAXPARM; i++)
        {
            nonl_computed_item[i] = CreateTextItem2(rc2, 15, (char *)"");
        }
        XtManageChild(rc1);
        XtManageChild(rc2);
        XtManageChild(rc);
        XtVaSetValues(sw,
                      XmNworkWindow, rc,
                      NULL);

        rc = XmCreateRowColumn(nonl_panel, (char *)"rc", NULL, 0);
        CreateCommandButtons(rc, 2, but1, label1);
        XtAddCallback(but1[0], XmNactivateCallback,
                      (XtCallbackProc)do_nonl_proc, (XtPointer)NULL);
        /*
         XtAddCallback(but1[1], XmNactivateCallback,
                (XtCallbackProc) create_nonleval_frame, (XtPointer) NULL);
      */
        XtAddCallback(but1[1], XmNactivateCallback,
                      (XtCallbackProc)destroy_dialog, (XtPointer)nonl_frame);
        XtManageChild(rc);

        XtVaSetValues(fr,
                      XmNtopAttachment, XmATTACH_FORM,
                      XmNleftAttachment, XmATTACH_FORM,
                      XmNrightAttachment, XmATTACH_FORM,
                      NULL);
        XtVaSetValues(sw,
                      XmNtopAttachment, XmATTACH_WIDGET,
                      XmNtopWidget, fr,
                      XmNleftAttachment, XmATTACH_FORM,
                      XmNrightAttachment, XmATTACH_FORM,
                      XmNbottomAttachment, XmATTACH_WIDGET,
                      XmNbottomWidget, rc,
                      NULL);
        XtVaSetValues(rc,
                      XmNleftAttachment, XmATTACH_FORM,
                      XmNrightAttachment, XmATTACH_FORM,
                      XmNbottomAttachment, XmATTACH_FORM,
                      NULL);

        XtManageChild(nonl_panel);
    }
    XtRaise(nonl_frame);
    unset_wait_cursor();
}
Esempio n. 2
0
static void label_props_notify_proc(Widget, XtPointer, XtPointer)
{
    Widget wlabel, rc, rc2, rc3, fr;
    int x, y;
    set_wait_cursor();
    if (labelprops_frame == NULL)
    {
        Widget buts[2];
        char *label1[2];
        label1[0] = (char *)"Accept";
        label1[1] = (char *)"Close";
        XmGetPos(app_shell, 0, &x, &y);
        labelprops_frame = XmCreateDialogShell(app_shell, (char *)"Title/Subtitle props", NULL, 0);
        handle_close(labelprops_frame);
        XtVaSetValues(labelprops_frame, XmNx, x, XmNy, y, NULL);
        labelprops_panel = XtVaCreateWidget("labelprops panel",
                                            xmRowColumnWidgetClass, labelprops_frame,
                                            NULL);

        rc = XmCreateRowColumn(labelprops_panel, (char *)"rc", NULL, 0);
        XtVaSetValues(rc,
                      XmNorientation, XmHORIZONTAL,
                      NULL);

        fr = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, rc,
                                     NULL);
        rc2 = XtVaCreateManagedWidget("rc2", xmRowColumnWidgetClass, fr,
                                      NULL);
        XtVaCreateManagedWidget("Title:", xmLabelWidgetClass, rc2,
                                NULL);
        title_font_item = CreatePanelChoice(rc2, "Font:",
                                            11,
                                            "Times-Roman", "Times-Bold", "Times-Italic",
                                            "Times-BoldItalic", "Helvetica",
                                            "Helvetica-Bold", "Helvetica-Oblique",
                                            "Helvetica-BoldOblique", "Greek", "Symbol",
                                            0,
                                            0);
        wlabel = XtVaCreateManagedWidget("Character size:", xmLabelWidgetClass, rc2,
                                         NULL);
        title_size_item = XtVaCreateManagedWidget("stringsize", xmScaleWidgetClass, rc2,
                                                  XmNminimum, 0,
                                                  XmNmaximum, 400,
                                                  XmNvalue, 100,
                                                  XmNshowValue, True,
                                                  XmNprocessingDirection, XmMAX_ON_RIGHT,
                                                  XmNorientation, XmHORIZONTAL,
                                                  NULL);

        rc3 = XmCreateRowColumn(rc2, (char *)"rc3", NULL, 0);
        XtVaSetValues(rc3, XmNorientation, XmHORIZONTAL, NULL);
        title_color_item = CreateColorChoice(rc3, "Color:", 0);
        title_linew_item = CreatePanelChoice(rc3, "Width:",
                                             10,
                                             "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
                                             0);
        XtManageChild(rc3);
        XtManageChild(rc2);
        XtManageChild(fr);

        fr = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, rc,
                                     NULL);
        rc2 = XtVaCreateManagedWidget("rc2", xmRowColumnWidgetClass, fr,
                                      NULL);
        wlabel = XtVaCreateManagedWidget("Subtitle:", xmLabelWidgetClass, rc2,
                                         NULL);
        stitle_font_item = CreatePanelChoice(rc2, "Font:",
                                             11,
                                             "Times-Roman", "Times-Bold", "Times-Italic",
                                             "Times-BoldItalic", "Helvetica",
                                             "Helvetica-Bold", "Helvetica-Oblique",
                                             "Helvetica-BoldOblique", "Greek", "Symbol",
                                             0,
                                             0);
        wlabel = XtVaCreateManagedWidget("Character size:", xmLabelWidgetClass, rc2,
                                         NULL);
        stitle_size_item = XtVaCreateManagedWidget("stringsize", xmScaleWidgetClass, rc2,
                                                   XmNminimum, 0,
                                                   XmNmaximum, 400,
                                                   XmNvalue, 100,
                                                   XmNshowValue, True,
                                                   XmNprocessingDirection, XmMAX_ON_RIGHT,
                                                   XmNorientation, XmHORIZONTAL,
                                                   NULL);
        rc3 = XmCreateRowColumn(rc2, (char *)"rc3", NULL, 0);
        XtVaSetValues(rc3, XmNorientation, XmHORIZONTAL, NULL);
        stitle_color_item = CreateColorChoice(rc3, "Color:", 0);
        stitle_linew_item = CreatePanelChoice(rc3, "Width:",
                                              10,
                                              "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
                                              0);

        XtManageChild(rc3);
        XtManageChild(rc2);
        XtManageChild(fr);

        XtManageChild(rc);

        CreateCommandButtons(labelprops_panel, 2, buts, label1);
        XtAddCallback(buts[0], XmNactivateCallback,
                      (XtCallbackProc)labelprops_define_notify_proc, (XtPointer)NULL);
        XtAddCallback(buts[1], XmNactivateCallback,
                      (XtCallbackProc)destroy_dialog, (XtPointer)labelprops_frame);
        XtManageChild(labelprops_panel);
    }
    update_labelprops_proc();
    XtRaise(labelprops_frame);
    unset_wait_cursor();
}
Esempio n. 3
0
/* ARGSUSED */
void create_nonl_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
    int i;
    Widget sw, fr, title_fr, fr1, fr3, rc, rc1, rc2, rc3, lab, fitbut[4], but1[2];
    Widget menubar, menupane, submenupane, cascade;
    set_wait_cursor();
    if (nonl_frame == NULL) {
	char *fitlabel[4];
	char *blabel[2];

	fitlabel[0] = "Load as is";
	fitlabel[1] = "Run 5 steps";
	fitlabel[2] = "Run 20 steps";
	fitlabel[3] = "Run 100 steps";
	
	blabel[0] = "Accept";
	blabel[1] = "Cancel";

	nonl_frame = XmCreateDialogShell(app_shell, "Non-linear curve fitting", NULL, 0);
	handle_close(nonl_frame);
	nonl_panel = XmCreateForm(nonl_frame, "nonl_frame_rc", NULL, 0);

        menubar = CreateMenuBar(nonl_panel, "nonlMenuBar", NULL);
        
        menupane = CreateMenu(menubar, "nonlFileMenu", "File", 'F', NULL, NULL);
        CreateMenuButton(menupane, "open", "Open...", 'O',
            (XtCallbackProc) create_openfit_popup, (XtPointer) NULL, NULL);
        CreateMenuButton(menupane, "save", "Save...", 'S',
            (XtCallbackProc) create_savefit_popup, (XtPointer) NULL, NULL);
        CreateMenuSeparator(menupane, "sep1");
        CreateMenuButton(menupane, "close", "Close", 'C',
    	    (XtCallbackProc) destroy_nonl_frame, (XtPointer) NONL_ACCEPT, NULL);

        menupane = CreateMenu(menubar, "nonlDataMenu", "Data", 'D', NULL, NULL);

        CreateMenuButton(menupane, "reset", "Reset", 'R',
    	    (XtCallbackProc) reset_nonl_frame, (XtPointer) NULL, 0);
        CreateMenuButton(menupane, "update", "Update", 'U',
    	    (XtCallbackProc) update_nonl_frame, (XtPointer) NULL, 0);

        menupane = CreateMenu(menubar, "nonlOptionsMenu", "Options", 'O', NULL, NULL);
   
        submenupane = CreateMenu(menupane, "nonlLoadMenu", 
    				"Load", 'L', NULL, NULL);
    
        nonl_load_item[0] = CreateMenuToggle(submenupane, "values", "Fitted values", 'v',
	    (XtCallbackProc) do_nonl_toggle, (XtPointer) 0, NULL);
        nonl_load_item[1] = CreateMenuToggle(submenupane, "residuals", "Residuals", 'R',
	    (XtCallbackProc) do_nonl_toggle, (XtPointer) 1, NULL);
        nonl_load_item[2] = CreateMenuToggle(submenupane, "function", "Function", 'F',
	    (XtCallbackProc) do_nonl_toggle, (XtPointer) 2, NULL);

        nonl_autol_item = CreateMenuToggle(menupane, "autoload", "Autoload", 'A',
	    (XtCallbackProc) NULL, (XtPointer) NULL, NULL);

        menupane = CreateMenu(menubar, "nonlHelpMenu", "Help", 'H', &cascade, NULL);
        XtVaSetValues(menubar, XmNmenuHelpWidget, cascade, NULL);

        CreateMenuButton(menupane, "onFit", "On fit", 'f',
            (XtCallbackProc) HelpCB, (XtPointer) "trans.html#nlcurve", 0);

        CreateMenuButton(menupane, "onContext", "On context", 'x',
            (XtCallbackProc) ContextHelpCB, (XtPointer) NULL, 0);
        
        XtManageChild(menubar);
	XtVaSetValues(menubar,
		      XmNtopAttachment, XmATTACH_FORM,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment, XmATTACH_FORM,
		      NULL);
        
        fr1 = XmCreateFrame(nonl_panel, "nonl_frame", NULL, 0);
        nonl_set_item  = CreateSetSelector(fr1, "Apply to set:",
                                    SET_SELECT_ACTIVE,
                                    FILTER_SELECT_NONE,
                                    GRAPH_SELECT_CURRENT,
                                    SELECTION_TYPE_SINGLE);
	
	XtManageChild(fr1);
	XtVaSetValues(fr1,
		      XmNtopAttachment, XmATTACH_WIDGET,
		      XmNtopWidget, menubar,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment, XmATTACH_FORM,
		      NULL);
		      
	fr = XmCreateFrame(nonl_panel, "nonl_frame", NULL, 0);
	rc = XmCreateRowColumn(fr, "nonl_rc", NULL, 0);
	
	title_fr = XmCreateFrame(rc, "nonl_title_frame", NULL, 0);
	XtVaSetValues(title_fr, XmNshadowType, XmSHADOW_ETCHED_OUT, NULL);
	nonl_title_item = XmCreateLabel(title_fr, nonl_opts.title, NULL, 0);
    	XtManageChild(nonl_title_item);
	XtManageChild(title_fr);
    	
	nonl_formula_item = (Widget) CreateTextItem2(rc, 35, "Formula:");
	rc1 = XmCreateRowColumn(rc, "nonl_rc", NULL, 0);
	XtVaSetValues(rc1, XmNorientation, XmHORIZONTAL, NULL);
	
	nonl_nparm_item = CreatePanelChoice(rc1,
				   "Number of parameters:",
				   12,
				   "0",
				   "1",
				   "2",
				   "3",
				   "4",
				   "5",
				   "6",
				   "7",
				   "8",
				   "9",
				  "10",
				   NULL, NULL);

	for (i = 0; i < MAXPARM + 1; i++) {
	    XtAddCallback(nonl_nparm_item[2 + i], XmNactivateCallback,
			(XtCallbackProc) do_nparm_toggle, (XtPointer) i);
	}
	
	nonl_tol_item = CreateTextItem2(rc1, 10, "Tolerance:");
	
	XtManageChild(rc1);
	
	sw = XtVaCreateManagedWidget("sw",
				     xmScrolledWindowWidgetClass, rc,
				     XmNheight, 180,
				     XmNscrollingPolicy, XmAUTOMATIC,
				     NULL);

	rc2 = XmCreateRowColumn(sw, "rc2", NULL, 0);


	for (i = 0; i < MAXPARM; i++) {
	    nonl_parm_item[i] = XmCreateRowColumn(rc2, "rc1", NULL, 0);
	    XtVaSetValues(nonl_parm_item[i], XmNorientation, XmHORIZONTAL, NULL);
	    sprintf(buf, "A%1d: ", i);
	    nonl_value_item[i] = CreateTextItem2(nonl_parm_item[i], 10, buf);

	    nonl_constr_item[i] = XmCreateToggleButton(nonl_parm_item[i], "Bounds:", NULL, 0);
	    XtAddCallback(nonl_constr_item[i], XmNvalueChangedCallback, 
	    	    	    (XtCallbackProc) do_constr_toggle, (XtPointer) i);
	    XtManageChild(nonl_constr_item[i]);

	    nonl_lowb_item[i] = CreateTextItem2(nonl_parm_item[i], 6, "");
	    
	    sprintf(buf, "< A%1d < ", i);
	    lab = XmCreateLabel(nonl_parm_item[i], buf, NULL, 0);
    	    XtManageChild(lab);

	    nonl_uppb_item[i] = CreateTextItem2(nonl_parm_item[i], 6, "");
	    XtManageChild(nonl_parm_item[i]);
	}

	XtManageChild(rc2);
	XtManageChild(rc);
	XtManageChild(fr);

        XtVaSetValues(fr,
                      XmNtopAttachment, XmATTACH_WIDGET,
                      XmNtopWidget, fr1,
                      XmNleftAttachment, XmATTACH_FORM,
                      XmNrightAttachment, XmATTACH_FORM,
                      NULL);
                      
	fr3 = XmCreateFrame(nonl_panel, "nonl_frame", NULL, 0);
	rc3 = XmCreateRowColumn(fr3, "rc3", NULL, 0);
	
	CreateCommandButtons(rc3, 4, fitbut, fitlabel);
	XtAddCallback(fitbut[0], XmNactivateCallback,
	     		   (XtCallbackProc) do_nonl_proc, (XtPointer)   (0));
	XtAddCallback(fitbut[1], XmNactivateCallback,
	     		   (XtCallbackProc) do_nonl_proc, (XtPointer)   (5));
	XtAddCallback(fitbut[2], XmNactivateCallback,
	     		   (XtCallbackProc) do_nonl_proc, (XtPointer)  (20));	     		   
	XtAddCallback(fitbut[3], XmNactivateCallback,
	     		   (XtCallbackProc) do_nonl_proc, (XtPointer) (100));
	
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, rc3, NULL);	
	
	nonl_fload_rc = XmCreateRowColumn(rc3, "nonl_fload_rc", NULL, 0);
	XtVaSetValues(nonl_fload_rc, XmNorientation, XmHORIZONTAL, NULL);
	nonl_start_item = CreateTextItem2(nonl_fload_rc, 6, "Start load at:");
	nonl_stop_item = CreateTextItem2(nonl_fload_rc, 6, "Stop load at:");
	nonl_npts_item = CreateTextItem2(nonl_fload_rc, 4, "# of points:");
	XtManageChild(nonl_fload_rc);
	XtSetSensitive(nonl_fload_rc, False);

	CreateCommandButtons(rc3, 2, but1, blabel);
	XtAddCallback(but1[0], XmNactivateCallback,
		(XtCallbackProc) destroy_nonl_frame, (XtPointer) NONL_ACCEPT);
	XtAddCallback(but1[1], XmNactivateCallback,
		(XtCallbackProc) destroy_nonl_frame, (XtPointer) NONL_CANCEL);

	XtManageChild(rc3);
	XtManageChild(fr3);
	XtVaSetValues(fr3,
	              XmNtopAttachment, XmATTACH_WIDGET,
                      XmNtopWidget, fr,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment, XmATTACH_FORM,
		      XmNbottomAttachment, XmATTACH_FORM,
		      NULL);

	XtManageChild(nonl_panel);
    }
    update_nonl_frame();
    
    XtRaise(nonl_frame);
    
    unset_wait_cursor();
}
Esempio n. 4
0
/* ARGSUSED */
static void do_nonl_proc(Widget, XtPointer, XtPointer)
{
    int i, setno, loadset, loadto, graphto, npar, info;
    double tol, a[MAXPARM];
    char fstr[256];
    double *y, *yp;

    set_wait_cursor();
    curset = setno = (int)GetChoice(nonl_set_item);
    loadto = (int)GetChoice(nonl_load_item);
    graphto = (int)GetChoice(nonl_loadgraph_item) - 1;
    tol = atof((char *)xv_getstr(nonl_tol_item));
    if (graphto < 0)
    {
        graphto = cg;
    }
    npar = atoi((char *)xv_getstr(nonl_nparm_item));
    strcpy(fstr, (char *)xv_getstr(nonl_formula_item));
    for (i = 0; i < MAXPARM; i++)
    {
        a[i] = 0.0;
        strcpy(buf, (char *)xv_getstr(nonl_initial_item[i]));
        sscanf(buf, "%lf", &a[i]);
    }
    yp = (double *)calloc(getsetlength(cg, setno), sizeof(double));
    if (yp == NULL)
    {
        errwin("Memory allocation error, operation cancelled");
        unset_wait_cursor();
        return;
    }
    y = gety(cg, setno);
    for (i = 0; i < getsetlength(cg, setno); i++)
    {
        yp[i] = y[i];
    }
    sprintf(buf, "Fitting: %s\n", fstr);
    stufftext(buf, 0);
    sprintf(buf, "Initial guess:\n");
    stufftext(buf, 0);
    for (i = 0; i < npar; i++)
    {
        sprintf(buf, "\ta%1d = %.9lf\n", i, a[i]);
        stufftext(buf, 0);
    }
    sprintf(buf, "Tolerance = %.9lf\n", tol);
    stufftext(buf, 0);
    lmfit(fstr, getsetlength(cg, setno), getx(cg, setno),
          yp, y, npar, a, tol, &info);
    for (i = 0; i < getsetlength(cg, setno); i++)
    {
        y[i] = yp[i];
    }
    free(yp);
    for (i = 0; i < MAXPARM; i++)
    {
        sprintf(buf, "%.9lf", a[i]);
        xv_setstr(nonl_computed_item[i], buf);
        nonl_parms[i] = a[i];
    }
    if (info > 0 && info < 4)
    {
        sprintf(buf, "Computed values:\n");
        stufftext(buf, 0);
        for (i = 0; i < npar; i++)
        {
            sprintf(buf, "\ta%1d = %.9lf\n", i, a[i]);
            stufftext(buf, 0);
        }
        loadset = nextset(cg);
        if (loadset != -1)
        {
            do_copyset(cg, setno, cg, loadset);
        }
        else
        {
            unset_wait_cursor();
            return;
        }
        switch (loadto)
        {
        case 0:
            sprintf(buf, "Evaluating function and loading result to set %d:\n", loadset);
            stufftext(buf, 0);
            do_compute(loadset, 0, graphto, fstr);
            break;
        case 1:
            sprintf(buf, "Evaluating function and loading residuals to set %d:\n", loadset);
            stufftext(buf, 0);
            do_compute(loadset, 0, graphto, fstr);
            break;
        case 2:
            sprintf(buf, "Computed function not evaluated\n");
            stufftext(buf, 0);
            break;
        }
    }
    /*
       if (info >= 4) {
      do_compute(setno, 1, graphto, fstr);
       }
   */
    if (info >= 0 && info <= 7)
    {
        char *s;
        switch (info)
        {
        case 0:
            s = (char *)"Improper input parameters.\n";
            break;
        case 1:
            s = (char *)"Relative error in the sum of squares is at most tol.\n";
            break;
        case 2:
            s = (char *)"Relative error between A and the solution is at most tol.\n";
            break;
        case 3:
            s = (char *)"Relative error in the sum of squares and A and the solution is at most tol.\n";
            break;
        case 4:
            s = (char *)"Fvec is orthogonal to the columns of the jacobian to machine precision.\n";
            break;
        case 5:
            s = (char *)"Number of calls to fcn has reached or exceeded 200*(n+1).\n";
            break;
        case 6:
            s = (char *)"Tol is too small. No further reduction in the sum of squares is possible.\n";
            break;
        case 7:
            s = (char *)"Tol is too small. No further improvement in the approximate solution A is possible.\n";
            break;
        }
        stufftext(s, 0);
        stufftext((char *)"\n", 0);
    }
    unset_wait_cursor();
}
Esempio n. 5
0
static void ps_gui_setup(const Canvas *canvas, void *data)
{
    PS_UI_data *ui = (PS_UI_data *) data;
    PS_data *ps = ui->ps;
    
    set_wait_cursor();
    
    if (ui->frame == NULL) {
        char *title;
        Widget ps_setup_rc, fr, rc;
        OptionItem colorspace_ops[3] = {
            {PS_COLORSPACE_GRAYSCALE, "Grayscale"},
            {PS_COLORSPACE_RGB,       "RGB"      },
            {PS_COLORSPACE_CMYK,      "CMYK"     }
        };
        OptionItem docdata_ops[3] = {
            {PS_DOCDATA_7BIT,   "7bit"  },
            {PS_DOCDATA_8BIT,   "8bit"  },
            {PS_DOCDATA_BINARY, "Binary"}
        };
        OptionItem ops[3] = {
            {PS_MEDIA_FEED_AUTO,   "Automatic" },
            {PS_MEDIA_FEED_MATCH,  "Match size"},
            {PS_MEDIA_FEED_MANUAL, "Manual"    }
        };
        OptionItem font_ops[4] = {
            {PS_FONT_EMBED_NONE,  "None"               },
            {PS_FONT_EMBED_BUT13, "All but 13 standard"},
            {PS_FONT_EMBED_BUT35, "All but 35 standard"},
            {PS_FONT_EMBED_ALL,   "All"                }
        };
        
        if (ps->format == PS_FORMAT) {
            title = "PS options";
        } else {
            title = "EPS options";
        }
	ui->frame = CreateDialog(app_shell, title);

        ps_setup_rc = CreateVContainer(ui->frame);

	fr = CreateFrame(ps_setup_rc, "PS options");
        rc = CreateVContainer(fr);
	ui->level2 = CreateToggleButton(rc, "PS Level 2");
        ui->colorspace =
            CreateOptionChoice(rc, "Colorspace:", 1, 3, colorspace_ops);
	AddToggleButtonCB(ui->level2,
            colorspace_cb, ui->colorspace);
	ui->docdata =
            CreateOptionChoice(rc, "Document data:", 1, 3, docdata_ops);
	ui->fonts =
            CreateOptionChoice(rc, "Embed fonts:", 1, 4, font_ops);

        if (ps->format == EPS_FORMAT) {
	    ui->printable = CreateToggleButton(rc,
                "Printable as standalone");
        }
        
        if (ps->format == PS_FORMAT) {
	    fr = CreateFrame(ps_setup_rc, "Page offsets (pt)");
            rc = CreateHContainer(fr);
	    ui->offset_x = CreateSpinChoice(rc,
                "X: ", 4, SPIN_TYPE_INT, -999.0, 999.0, 10.0);
	    ui->offset_y = CreateSpinChoice(rc,
                "Y: ", 4, SPIN_TYPE_INT, -999.0, 999.0, 10.0);

	    fr = CreateFrame(ps_setup_rc, "Hardware");
            rc = CreateVContainer(fr);
	    ui->feed = CreateOptionChoice(rc, "Media feed:", 1, 3, ops);
	    ui->hwres = CreateToggleButton(rc, "Set hardware resolution");
        }

	CreateAACDialog(ui->frame, ps_setup_rc, set_ps_setup_proc, ui);
    }
    update_ps_setup_frame(ui);
    
    DialogRaise(ui->frame);
    unset_wait_cursor();
}
Esempio n. 6
0
/* ARGSUSED */
static void do_nonl_proc(Widget w, XtPointer client_data, XtPointer call_data)
{
    int i, npts = 0, info;
    double delx, *xfit, *y, *yfit;
    int nsteps = (int) client_data;
    
    set_wait_cursor();
    curset = nlsetno = GetSelectedSet(nonl_set_item);
    if (curset == SET_SELECT_ERROR) {
    	errmsg("No set selected");
    	unset_wait_cursor();
    	return;
    }
    
    nonl_opts.tolerance = atof((char *) xv_getstr(nonl_tol_item));
    nonl_opts.parnum = GetChoice(nonl_nparm_item);
    strcpy(nonl_opts.formula, (char *) xv_getstr(nonl_formula_item));
    for (i = 0; i < nonl_opts.parnum; i++) {
	strcpy(buf, (char *) xv_getstr(nonl_value_item[i]));
	if (sscanf(buf, "%lf", &nonl_parms[i].value) != 1) {
	    errmsg("Invalid input in parameter field");
	    unset_wait_cursor();
	    return;
	}
	
	nonl_parms[i].constr = XmToggleButtonGetState(nonl_constr_item[i]);
	if (nonl_parms[i].constr) {
	    strcpy(buf, (char *) xv_getstr(nonl_lowb_item[i]));
	    if (sscanf(buf, "%lf", &nonl_parms[i].min) != 1) {
	    	errmsg("Invalid input in low-bound field");
	    	unset_wait_cursor();
	    	return;
	    }
	    strcpy(buf, (char *) xv_getstr(nonl_uppb_item[i]));
	    if (sscanf(buf, "%lf", &nonl_parms[i].max) != 1) {
	    	errmsg("Invalid input in upper-bound field");
	    	unset_wait_cursor();
	    	return;
	    }
	    if ((nonl_parms[i].value < nonl_parms[i].min) || (nonl_parms[i].value > nonl_parms[i].max)) {
	    	errmsg("Initial values must be within bounds");
	    	unset_wait_cursor();
	    	return;
	    }
	}
    }
    
    nonl_prefs.autoload = XmToggleButtonGetState(nonl_autol_item);
    for (i = 0; i < 3; i++) {
        if (XmToggleButtonGetState(nonl_load_item[i])) {
            nonl_prefs.load = i;
            break;
        }
    }
    
    if (nonl_prefs.load == LOAD_FUNCTION) {
        strcpy(buf, (char *) xv_getstr(nonl_start_item));
	if (sscanf(buf, "%lf", &nonl_prefs.start) != 1) {
	    errmsg("Invalid input in start field");
	    unset_wait_cursor();
	    return;
	}
	strcpy(buf, (char *) xv_getstr(nonl_stop_item));
	if (sscanf(buf, "%lf", &nonl_prefs.stop) != 1) {
	    errmsg("Invalid input in stop field");
	    unset_wait_cursor();
	    return;
	}
	strcpy(buf, (char *) xv_getstr(nonl_npts_item));
	if (sscanf(buf, "%d", &nonl_prefs.npoints) != 1) {
	    errmsg("Invalid input in start field");
	    unset_wait_cursor();
	    return;
	}
    }
    
    if (nsteps) { /* we are asked to fit */
    	sprintf(buf, "Fitting with formula: %s\n", nonl_opts.formula);
    	stufftext(buf, 0);
    	sprintf(buf, "Initial guesses:\n");
    	stufftext(buf, 0);
    	for (i = 0; i < nonl_opts.parnum; i++) {
	    sprintf(buf, "\ta%1d = %g\n", i, nonl_parms[i].value);
	    stufftext(buf, 0);
    	}
    	sprintf(buf, "Tolerance = %g\n", nonl_opts.tolerance);
    	stufftext(buf, 0);

/*
 * The fit itself!
 */    	

    	info = do_nonlfit(cg, nlsetno, nsteps);
    	if (info == -1) {
	    errmsg("Memory allocation error in do_nonlfit()");  
	    unset_wait_cursor();
	    return;  	
    	}
   	    	
    	for (i = 0; i < nonl_opts.parnum; i++) {
	    sprintf(buf, "%g", nonl_parms[i].value);
	    xv_setstr(nonl_value_item[i], buf);
    	}

    	if ((info > 0 && info < 4) || (info == 5)) {
	    sprintf(buf, "Computed values:\n");
	    stufftext(buf, 0);
	    for (i = 0; i < nonl_opts.parnum; i++) {
		sprintf(buf, "\ta%1d = %g\n", i, nonl_parms[i].value);
		stufftext(buf, 0);
	    }
    	}


    	if (info >= 0 && info <= 7) {
    	    char *s;
    	    switch (info) {
    	    case 0:
    		s = "Improper input parameters.\n";
    		break;
    	    case 1:
    		s = "Relative error in the sum of squares is at most tol.\n";
    		break;
    	    case 2:
    		s = "Relative error between A and the solution is at most tol.\n";
    		break;
    	    case 3:
    		s = "Relative error in the sum of squares and A and the solution is at most tol.\n";
    		break;
    	    case 4:
    		s = "Fvec is orthogonal to the columns of the jacobian to machine precision.\n";
    		break;
    	    case 5:
    		s = "\n";
    		break;
    	    case 6:
    		s = "Tol is too small. No further reduction in the sum of squares is possible.\n";
    		break;
    	    case 7:
    		s = "Tol is too small. No further improvement in the approximate solution A is possible.\n";
    		break;
    	    default:
    		s = "\n";
    		errmsg("Internal error in do_nonl_proc(), please report");
    		break;
    	    }
    	    stufftext(s, 0);
    	    stufftext("\n", 0);
    	}
    } /* endif (nsteps) */

/*
 * Select & activate a set to load results to
 */    
    if (!nsteps || nonl_prefs.autoload) {
    	/* check if the set is already allocated */
    	if ((nlloadset == -1) || (nlloadset == nlsetno) || !getsetlength(cg, nlloadset)) {
    	    nlloadset = nextset(cg);
    	    if (nlloadset == -1) {
    	      errmsg("No more sets!");
    	      unset_wait_cursor();
    	      return;
    	    } else {
    		activateset(cg, nlloadset);
    		setlength(cg, nlloadset, 1);
    	    }
    	}
    	    	
    	switch (nonl_prefs.load) {
    	case LOAD_VALUES:
    	  sprintf(buf, "Evaluating fitted values and loading result to set %d:\n", nlloadset);
    	  stufftext(buf, 0);
    	  npts = getsetlength(cg, nlsetno);
    	  setlength(cg, nlloadset, npts);
    	  copycol2(cg, nlsetno, cg, nlloadset, 0);
    	  break;
    	case LOAD_RESIDUALS:
    	  sprintf(buf, "Evaluating fitted values and loading residuals to set %d:\n", nlloadset);
    	  stufftext(buf, 0);
    	  npts = getsetlength(cg, nlsetno);
    	  setlength(cg, nlloadset, npts);
    	  copycol2(cg, nlsetno, cg, nlloadset, 0);
    	  break;
    	case LOAD_FUNCTION:
    	  sprintf(buf, "Computing fitting function and loading result to set %d:\n", nlloadset);
    	  stufftext(buf, 0);
    	  
    	  npts  = nonl_prefs.npoints;
    	  if (npts <= 1) {
    	      errmsg("Number of points must be > 1");
    	      unset_wait_cursor();
    	      return;
    	  }
    	  
    	  setlength(cg, nlloadset, npts);
    	  
    	  delx = (nonl_prefs.stop - nonl_prefs.start)/(npts - 1);
    	  xfit = getx(cg, nlloadset);
	  for (i = 0; i < npts; i++) {
	      xfit[i] = nonl_prefs.start + i * delx;
	  }
    	  break;
    	}
    	
    	setcomment(cg, nlloadset, nonl_opts.formula);
    	
    	do_compute(nlloadset, 0, cg, nonl_opts.formula);
    	
    	if (nonl_prefs.load == LOAD_RESIDUALS) { /* load residuals */
    	    y = gety(cg, nlsetno);
    	    yfit = gety(cg, nlloadset);
    	    for (i = 0; i < npts; i++) {
	      yfit[i] -= y[i];
	    }
    	}
    	
    	update_set_lists(cg);
    	drawgraph();
    }
    unset_wait_cursor();
}
Esempio n. 7
0
void create_hotlinks_popup(Widget, XtPointer, XtPointer)
{
    int x, y;
    static Widget top, dialog;
    Arg args[3];
    set_wait_cursor();
    if (top == NULL)
    {
        char *label1[5];
        Widget but1[5];
        label1[0] = (char *)"Link";
        label1[1] = (char *)"Files...";
        label1[2] = (char *)"Unlink";
        label1[3] = (char *)"Update";
        label1[4] = (char *)"Close";
        XmGetPos(app_shell, 0, &x, &y);
        top = XmCreateDialogShell(app_shell, (char *)"Hot links", NULL, 0);
        handle_close(top);
        XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
        dialog = XmCreateRowColumn(top, (char *)"dialog_rc", NULL, 0);

        XtSetArg(args[0], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE);
        XtSetArg(args[1], XmNvisibleItemCount, 5);
        hotlink_list_item = XmCreateScrolledList(dialog, (char *)"list", args, 2);
        XtManageChild(hotlink_list_item);

        hotlink_set_item = CreateSetSelector(dialog, "Link set:",
                                             SET_SELECT_ACTIVE,
                                             FILTER_SELECT_ALL,
                                             GRAPH_SELECT_CURRENT,
                                             SELECTION_TYPE_MULTIPLE);
        DefineSetSelectorFilter(&hotlink_set_item);

        hotlink_file_item = CreateTextItem2(dialog, 30, "To file or pipe:");
        hotlink_source_item = CreatePanelChoice(dialog, "Source: ", 3,
                                                "Disk file",
                                                "Pipe",
                                                NULL,
                                                NULL);

        XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);

        CreateCommandButtons(dialog, 5, but1, label1);
        XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc)do_hotlink_proc,
                      (XtPointer)NULL);
        XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc)create_hotfiles_popup,
                      (XtPointer)NULL);
        XtAddCallback(but1[2], XmNactivateCallback, (XtCallbackProc)do_hotunlink_proc,
                      (XtPointer)NULL);
        XtAddCallback(but1[3], XmNactivateCallback, (XtCallbackProc)do_hotupdate_proc,
                      (XtPointer)NULL);
        XtAddCallback(but1[4], XmNactivateCallback, (XtCallbackProc)destroy_dialog,
                      (XtPointer)top);

        XtManageChild(dialog);
        hotlink_frame = top;
    }
    XtRaise(top);
    update_hotlinks();
    unset_wait_cursor();
}
Esempio n. 8
0
void create_featext_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
    int x, y, i;
    Widget dialog;
    set_wait_cursor();
    if (feui.top == NULL) {
	char *label2[3];
	label2[0] = "Accept";
	label2[1] = "Close";
	XmGetPos(app_shell, 0, &x, &y);
	feui.top = XmCreateDialogShell(app_shell, "Feature Extraction", NULL, 0);
	handle_close(feui.top);
	XtVaSetValues(feui.top, XmNx, x, XmNy, y, NULL);
	dialog = XmCreateRowColumn(feui.top, "dialog_rc", NULL, 0);

	feui.tograph = CreateGraphChoice(dialog, "Results to graph: ", maxgraph, 1);
	feui.feature_item = CreatePanelChoice0(dialog,
					  "Feature:", 3, 24,
					  "Y minimum", "Y maximum", "Y average", "Y std. dev.",
					  "Y median",
					  "X minimum", "X maximum", "X average", "X std. dev.",
					  "X median",
					  "Frequency", "Period", "Zero crossing", 
					  "Rise time", "Fall time", "Slope", "Y intercept", 
					  "Set length", "Half maximal width", 
					  "Barycenter X", "Barycenter Y", 
					  "X(Y max)", "Y(X max)",
					  NULL, 0);
	feui.xval_item = CreatePanelChoice(dialog,
						"X values from:", 5,
						"Index", "Legends", "X from Set", "Y from set",
						NULL, 0 );
	
	for (i = 0; i < 4; i++) {
	    XtAddCallback(feui.xval_item[2 + i], XmNactivateCallback,
			(XtCallbackProc) do_fext_toggle, (XtPointer) i);
	}
	
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);

	feui.legload_rc= XmCreateRowColumn(dialog, "fext_legload_rc", NULL, 0);
	
	feui.absic_graph = CreateGraphChoice(feui.legload_rc,
								"Abscissa from graph: ",maxgraph,0);
	for(i=0; i<maxgraph; i++ )
	    XtAddCallback(feui.absic_graph[2 + i], XmNactivateCallback,
			(XtCallbackProc) do_gto_setsel_update, (XtPointer) i);
	
	feui.absic_set = CreateSetSelector(feui.legload_rc, "set:",
					SET_SELECT_ACTIVE,
					FILTER_SELECT_NONE,
					0,
					SELECTION_TYPE_SINGLE);
	update_save_set_list( feui.absic_set, 0 );
	
	XtManageChild(feui.legload_rc);
	XtSetSensitive(feui.legload_rc, False);
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);

	CreateCommandButtons(dialog, 2, but2, label2);
	XtAddCallback(but2[0], XmNactivateCallback, (XtCallbackProc)
	do_fext_proc,(XtPointer) & feui);
	XtAddCallback(but2[1], XmNactivateCallback,
	(XtCallbackProc)destroy_dialog,(XtPointer)feui.top);

	XtManageChild(dialog);
    }
    XtRaise(feui.top);
    unset_wait_cursor();
}
Esempio n. 9
0
static void do_ticklabels_proc(Widget w, XtPointer client_data, XtPointer call_data)
{
    Widget wlabel, rc;
    int x, y;
    set_wait_cursor();
    if (ticklabel_frame == NULL) {
	char *label1[2];
	label1[0] = "Accept";
	label1[1] = "Close";
	XmGetPos(app_shell, 0, &x, &y);
	ticklabel_frame = XmCreateDialogShell(app_shell, "Tick labels", NULL, 0);
	handle_close(ticklabel_frame);
	XtVaSetValues(ticklabel_frame, XmNx, x, XmNy, y, NULL);
	ticklabel_panel = XmCreateRowColumn(ticklabel_frame, "ticklabel_rc", NULL, 0);

	tlfont = CreatePanelChoice(ticklabel_panel, "Font:",
				   11,
				"Times-Roman", "Times-Bold", "Times-Italic",
				   "Times-BoldItalic", "Helvetica",
				   "Helvetica-Bold", "Helvetica-Oblique",
				 "Helvetica-BoldOblique", "Greek", "Symbol",
				   0,
				   0);

	rc = XmCreateRowColumn(ticklabel_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	tlcolor = CreateColorChoice(rc, "Color:", 0);

	tllinew = CreatePanelChoice(rc, "Line width:",
				    10,
			     "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
				    0);
	XtManageChild(rc);

	rc = XmCreateRowColumn(ticklabel_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	wlabel = XtVaCreateManagedWidget("Char size:", xmLabelWidgetClass, rc,
					 NULL);
	tlcharsize = XtVaCreateManagedWidget("stringsize", xmScaleWidgetClass, rc,
					     XmNminimum, 0,
					     XmNmaximum, 400,
					     XmNvalue, 0,
					     XmNshowValue, True,
				     XmNprocessingDirection, XmMAX_ON_RIGHT,
					     XmNorientation, XmHORIZONTAL,
					     NULL);
	XtManageChild(rc);
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticklabel_panel, NULL);

	tlform = CreatePanelChoice0(ticklabel_panel,
				    "Format:", 4,
				    30,
				    "Decimal",
				    "Exponential",
				    "Power",
				    "General",
				    "DD-MM-YY",
				    "MM-DD-YY",
				    "YY-MM-DD",
				    "MM-YY",
				    "MM-DD",
				    "Month-DD",
				    "DD-Month",
				    "Month (abrev.)",
				    "Month (abrev.)-YY",
				    "Month",
				    "Day of week (abrev.)",
				    "Day of week",
				    "Day of year",
				    "HH:MM:SS.s",
				    "MM-DD HH:MM:SS.s",
				    "MM-DD-YY HH:MM:SS.s",
				    "YY-MM-DD HH:MM:SS.s",
				    "Degrees (lon)",
				    "DD MM' (lon)",
				    "DD MM' SS.s\" (lon)",
				    "MM' SS.s\" (lon)",
				    "Degrees (lat)",
				    "DD MM' (lat)",
				    "DD MM' SS.s\" (lat)",
				    "MM' SS.s\" (lat)", 0,
				    0);

	tlprec = CreatePanelChoice(ticklabel_panel, "Precision:",
				   11,
			"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
				   0);
	tlappstr = CreateTextItem2(ticklabel_panel, 10, "Append to labels:");
	tlprestr = CreateTextItem2(ticklabel_panel, 10, "Prepend to labels:");

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticklabel_panel, NULL);

	tlstagger = CreatePanelChoice(ticklabel_panel, "Stagger labels:",
				      11,
			"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
				      0);

	tlskip = CreatePanelChoice(ticklabel_panel, "Skip every:",
				   11,
			"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
				   0);
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticklabel_panel, NULL);

	rc = XmCreateRowColumn(ticklabel_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	tlstarttype = CreatePanelChoice(rc, "Start labels at:",
					3,
					"Graph min", "Specified:", 0,
					0);
	tlstart = XtVaCreateManagedWidget("tlstart", xmTextWidgetClass, rc,
					  XmNtraversalOn, True,
					  XmNcolumns, 10,
					  NULL);
	XtManageChild(rc);

	rc = XmCreateRowColumn(ticklabel_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	tlstoptype = CreatePanelChoice(rc, "Stop labels at:",
				       3,
				       "Graph max", "Specified:", 0,
				       0);
	tlstop = XtVaCreateManagedWidget("tlstop", xmTextWidgetClass, rc,
					 XmNtraversalOn, True,
					 XmNcolumns, 10,
					 NULL);
	XtManageChild(rc);

	tlloc = (Widget *) CreatePanelChoice(ticklabel_panel, "Location:",
						3,
						"On ticks",
						"Between ticks",
						NULL,
						NULL);

	rc = XmCreateRowColumn(ticklabel_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	tllayout = (Widget *) CreatePanelChoice(rc, "Layout:",
						4,
						"Horizontal",
						"Vertical",
						"Specified (degrees):",
						NULL,
						NULL);
	tlangle = XtVaCreateManagedWidget("ticklangle", xmScaleWidgetClass, rc,
					  XmNminimum, 0,
					  XmNmaximum, 360,
					  XmNvalue, 100,
					  XmNshowValue, True,
					  XmNprocessingDirection, XmMAX_ON_RIGHT,
					  XmNorientation, XmHORIZONTAL,
					  NULL);
	XtManageChild(rc);
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticklabel_panel, NULL);

	ticklop = CreatePanelChoice(ticklabel_panel, "Draw tick labels on:",
				    4,
				  "Normal side", "Opposite side", "Both", 0,
				    0);

	tlsign = CreatePanelChoice(ticklabel_panel, "Sign of label:",
				   4,
				   "As is", "Absolute value", "Negate",
				   NULL,
				   0);

	ticklabel_applyto = CreatePanelChoice(ticklabel_panel, "Apply to:",
					      5,
					      "Current axis",
					      "All axes, current graph",
					      "Current axis, all graphs",
					      "All axes, all graphs",
					      NULL,
					      0);

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticklabel_panel, NULL);

	CreateCommandButtons(ticklabel_panel, 2, but1, label1);

	XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) accept_ticklabel_proc, (XtPointer) 0);
	XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) ticklabel_frame);

	XtManageChild(ticklabel_panel);
    }
    XtRaise(ticklabel_frame);
    update_ticklabel_items(cg);
    unset_wait_cursor();
}
Esempio n. 10
0
static void do_axislabel_proc(Widget w, XtPointer client_data, XtPointer call_data)
{
    Widget wlabel, rc;
    int x, y;
    set_wait_cursor();
    if (axislabel_frame == NULL) {
	char *label1[2];
	label1[0] = "Accept";
	label1[1] = "Close";
	XmGetPos(app_shell, 0, &x, &y);
	axislabel_frame = XmCreateDialogShell(app_shell, "Axis label", NULL, 0);
	handle_close(axislabel_frame);
	XtVaSetValues(axislabel_frame, XmNx, x, XmNy, y, NULL);
	axislabel_panel = XmCreateRowColumn(axislabel_frame, "axislabel_rc", NULL, 0);

	axislabellayout = (Widget *) CreatePanelChoice(axislabel_panel, "Axis layout:",
						       3,
						       "Parallel to axis",
						    "Perpendicular to axis",
						       NULL,
						       NULL);

	axislabelplace = (Widget *) CreatePanelChoice(axislabel_panel, "Axis label location:",
						       3,
						       "Auto",
						    "Specified",
						       NULL,
						       NULL);
	axislabelspec = CreateTextItem2(axislabel_panel, 10, "Location:");

	axislabelfont = CreatePanelChoice(axislabel_panel, "Font:",
					  11,
				"Times-Roman", "Times-Bold", "Times-Italic",
					  "Times-BoldItalic", "Helvetica",
				      "Helvetica-Bold", "Helvetica-Oblique",
				 "Helvetica-BoldOblique", "Greek", "Symbol",
					  0,
					  0);

 
	rc = XmCreateRowColumn(axislabel_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	axislabelcolor = CreateColorChoice(rc, "Color:", 0);
	axislabellinew = CreatePanelChoice(rc, "Line width:",
					   10,
			     "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
					   0);
	XtManageChild(rc);

	wlabel = XtVaCreateManagedWidget("Size:", xmLabelWidgetClass, axislabel_panel,
					 NULL);
	axislabelcharsize = XtVaCreateManagedWidget("stringsize", xmScaleWidgetClass, axislabel_panel,
						    XmNminimum, 0,
						    XmNmaximum, 400,
						    XmNvalue, 100,
						    XmNshowValue, True,
				     XmNprocessingDirection, XmMAX_ON_RIGHT,
					       XmNorientation, XmHORIZONTAL,
						    NULL);

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, axislabel_panel, NULL);

	CreateCommandButtons(axislabel_panel, 2, but1, label1);
	XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) accept_axislabel_proc, (XtPointer) 0);
	XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) axislabel_frame);

	XtManageChild(axislabel_panel);
    }
    XtRaise(axislabel_frame);
    update_axislabel_items(cg);
    unset_wait_cursor();
}
Esempio n. 11
0
/*
 * Create the ticks popup
 */
void create_ticks_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
    Widget wbut, rc;
    int x, y;
    int i;
    set_wait_cursor();
    if (ticks_frame == NULL) {
	char *label1[2];
	label1[0] = "Accept";
	label1[1] = "Close";
	XmGetPos(app_shell, 0, &x, &y);
	ticks_frame = XmCreateDialogShell(app_shell, "Axes", NULL, 0);
	handle_close(ticks_frame);
	XtVaSetValues(ticks_frame, XmNx, x, XmNy, y, NULL);
	ticks_panel = XmCreateRowColumn(ticks_frame, "ticks_rc", NULL, 0);

	editaxis = (Widget *) CreatePanelChoice(ticks_panel, "Edit:",
						5,
						"X axis",
						"Y axis",
						"Zero X axis",
						"Zero Y axis",
						NULL,
						NULL);
	for (i = 0; i < 4; i++) {
	    XtAddCallback(editaxis[2 + i], XmNactivateCallback, (XtCallbackProc) set_axis_proc, (XtPointer) (intptr_t) i);
	}

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticks_panel, NULL);
	axislabel = CreateTextItem2(ticks_panel, 30, "Axis label:");
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticks_panel, NULL);
	tmajor = CreateTextItem2(ticks_panel, 10, "Major tick spacing:");
	tminor = CreateTextItem2(ticks_panel, 10, "Minor tick spacing:");

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticks_panel, NULL);
	tlonoff = XtVaCreateManagedWidget("Display tick labels",
				     xmToggleButtonWidgetClass, ticks_panel,
					  NULL);
	tonoff = XtVaCreateManagedWidget("Display tick marks",
				     xmToggleButtonWidgetClass, ticks_panel,
					 NULL);
	baronoff = XtVaCreateManagedWidget("Display axis bar",
				     xmToggleButtonWidgetClass, ticks_panel,
					   NULL);

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticks_panel, NULL);
	rc = XmCreateRowColumn(ticks_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	wbut = XtVaCreateManagedWidget("Axis props...", xmPushButtonWidgetClass, rc,
				       NULL);
	XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) do_axis_proc, (XtPointer) 0);
	wbut = XtVaCreateManagedWidget("Axis label...", xmPushButtonWidgetClass, rc,
				       NULL);
	XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) do_axislabel_proc, (XtPointer) 0);
	wbut = XtVaCreateManagedWidget("Tick labels...", xmPushButtonWidgetClass, rc,
				       NULL);
	XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) do_ticklabels_proc, (XtPointer) 0);
	XtManageChild(rc);

	rc = XmCreateRowColumn(ticks_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);
	wbut = XtVaCreateManagedWidget("Tick marks...", xmPushButtonWidgetClass, rc,
				       NULL);
	XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) do_tickmarks_proc, (XtPointer) 0);
	wbut = XtVaCreateManagedWidget("Axis bar...", xmPushButtonWidgetClass, rc,
				       NULL);
	XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) do_axisbar_proc, (XtPointer) 0);
	wbut = XtVaCreateManagedWidget("User ticks/tick labels...",
				       xmPushButtonWidgetClass, rc,
				       NULL);
	XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) do_special_proc, (XtPointer) 0);
	XtManageChild(rc);
	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticks_panel, NULL);
	axis_applyto = (Widget *) CreatePanelChoice(ticks_panel,
						    "Apply to:",
						    5,
						    "Current axis",
						    "All axes, current graph",
						    "Current axis, all graphs",
						    "All axes, all graphs",
						    NULL,
						    NULL);

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, ticks_panel, NULL);

	CreateCommandButtons(ticks_panel, 2, but1, label1);
	XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) ticks_define_notify_proc, (XtPointer) 0);
	XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) ticks_frame);

	XtManageChild(ticks_panel);
    }
    XtRaise(ticks_frame);
    update_ticks(cg);
    unset_wait_cursor();
}
Esempio n. 12
0
static void do_special_proc(Widget w, XtPointer client_data, XtPointer call_data)
{
    Widget wlabel, rc, rc3, sw;
    int i, x, y;
    char buf[10];
    set_wait_cursor();
    if (special_frame == NULL) {
	char *label1[2];
	label1[0] = "Accept";
	label1[1] = "Close";
	XmGetPos(app_shell, 0, &x, &y);
	special_frame = XmCreateDialogShell(app_shell, "Specified ticks/ticklabels", NULL, 0);
	handle_close(special_frame);
	XtVaSetValues(special_frame, XmNx, x, XmNy, y, NULL);
	special_panel = XmCreateForm(special_frame, "special_form", NULL, 0);

	rc = XmCreateRowColumn(special_panel, "rc", NULL, 0);
	specticks = XtVaCreateManagedWidget("Use special tick locations",
					    xmToggleButtonWidgetClass, rc,
					    NULL);
	specticklabels = XtVaCreateManagedWidget("Use special tick labels",
					      xmToggleButtonWidgetClass, rc,
						 NULL);

	nspec = CreateTextItem2(rc, 10, "# of user ticks/labels to use:");
	wlabel = XtVaCreateManagedWidget("Tick location - Label:", xmLabelWidgetClass,
					 rc, NULL);
	XtManageChild(rc);
	XtVaSetValues(rc,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment, XmATTACH_FORM,
		      XmNtopAttachment, XmATTACH_FORM,
		      NULL);

	sw = XtVaCreateManagedWidget("sw",
				 xmScrolledWindowWidgetClass, special_panel,
				     XmNscrollingPolicy, XmAUTOMATIC,
				     XmNtopAttachment, XmATTACH_WIDGET,
				     XmNtopWidget, rc,
				     XmNleftAttachment, XmATTACH_FORM,
				     XmNrightAttachment, XmATTACH_FORM,
				     NULL);
	rc = XmCreateRowColumn(sw, "rc", NULL, 0);
	XtVaSetValues(sw,
		      XmNworkWindow, rc,
		      NULL);

	for (i = 0; i < MAX_TICK_LABELS; i++) {
	    rc3 = XmCreateRowColumn(rc, "rc3", NULL, 0);
	    XtVaSetValues(rc3, XmNorientation, XmHORIZONTAL, NULL);
	    sprintf(buf, "%2d", i + 1);
	    specnum[i] = XtVaCreateManagedWidget(buf, xmLabelWidgetClass, rc3,
						 NULL);
	    specloc[i] = XtVaCreateManagedWidget("tickmark", xmTextFieldWidgetClass, rc3,
						 XmNcolumns, 10,
						 NULL);
	    speclabel[i] = XtVaCreateManagedWidget("ticklabel", xmTextFieldWidgetClass, rc3,
						   XmNcolumns, 35,
						   NULL);
	    XtManageChild(rc3);
	}
	XtManageChild(rc);
	XtManageChild(sw);

	rc = XmCreateRowColumn(special_panel, "rc", NULL, 0);
	XtVaSetValues(rc, XmNorientation, XmHORIZONTAL, NULL);

	CreateCommandButtons(rc, 2, but1, label1);
	XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) accept_special_proc, (XtPointer) 0);
	XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) special_frame);
	XtManageChild(rc);
	XtVaSetValues(rc,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment, XmATTACH_FORM,
		      XmNbottomAttachment, XmATTACH_FORM,
		      NULL);
	XtVaSetValues(sw,
		      XmNbottomAttachment, XmATTACH_WIDGET,
		      XmNbottomWidget, rc,
		      NULL);

	load_special(cg, curaxis);
	XtManageChild(special_panel);
    }
    XtRaise(special_frame);
    update_special_items(cg);
    unset_wait_cursor();
}
Esempio n. 13
0
static void do_tickmarks_proc(Widget w, XtPointer client_data, XtPointer call_data)
{
    Widget wlabel, rc, rc2, rc3, fr;
    int x, y;
    set_wait_cursor();
    if (tickmark_frame == NULL) {
	char *label1[2];
	label1[0] = "Accept";
	label1[1] = "Close";
	XmGetPos(app_shell, 0, &x, &y);
	tickmark_frame = XmCreateDialogShell(app_shell, "Tick marks", NULL, 0);
	handle_close(tickmark_frame);
	XtVaSetValues(tickmark_frame, XmNx, x, XmNy, y, NULL);
	tickmark_panel = XmCreateRowColumn(tickmark_frame, "tickmark_rc", NULL, 0);

	tinout = CreatePanelChoice(tickmark_panel, "Tick marks pointing:",
				   4,
				   "In", "Out", "Both", 0,
				   0);

	tickop = CreatePanelChoice(tickmark_panel, "Draw tick marks on:",
				   4,
			    "Normal side", "Opposite side", "Both sides", 0,
				   0);

	rc2 = XmCreateRowColumn(tickmark_panel, "rc2", NULL, 0);
	XtVaSetValues(rc2, XmNorientation, XmHORIZONTAL, NULL);

/* major tick marks */
	fr = XmCreateFrame(rc2, "fr", NULL, 0);
	rc = XmCreateRowColumn(fr, "rc", NULL, 0);

	tgrid = XtVaCreateManagedWidget("Major ticks grid lines",
					xmToggleButtonWidgetClass, rc,
					NULL);

	rc3 = XmCreateRowColumn(rc, "rc3", NULL, 0);
	wlabel = XtVaCreateManagedWidget("Major tick length:", xmLabelWidgetClass, rc3,
					 NULL);
	tlen = XtVaCreateManagedWidget("ticklength", xmScaleWidgetClass, rc3,
				       XmNminimum, 0,
				       XmNmaximum, 400,
				       XmNvalue, 100,
				       XmNshowValue, True,
				       XmNprocessingDirection, XmMAX_ON_RIGHT,
				       XmNorientation, XmHORIZONTAL,
				       NULL);
	XtManageChild(rc3);

	tgridcol = CreateColorChoice(rc, "Color:", 0);

	tgridlinew = CreatePanelChoice(rc, "Line width:",
				       10,
			     "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
				       0);
	tgridlines = (Widget *) CreatePanelChoice(rc, "Line style:",
						  6,
						  "Solid line",
						  "Dotted line",
						  "Dashed line",
						  "Long Dashed",
						  "Dot-dashed",
						  NULL,
						  NULL);
	XtManageChild(rc);
	XtManageChild(fr);

	fr = XmCreateFrame(rc2, "fr", NULL, 0);
	rc = XmCreateRowColumn(fr, "rc", NULL, 0);

	tmgrid = XtVaCreateManagedWidget("Minor ticks grid lines", xmToggleButtonWidgetClass, rc,
					 NULL);
	rc3 = XmCreateRowColumn(rc, "rc", NULL, 0);
	wlabel = XtVaCreateManagedWidget("Minor tick length:", xmLabelWidgetClass, rc3,
					 NULL);
	tmlen = XtVaCreateManagedWidget("mticklength", xmScaleWidgetClass, rc3,
					XmNminimum, 0,
					XmNmaximum, 400,
					XmNvalue, 100,
					XmNshowValue, True,
				     XmNprocessingDirection, XmMAX_ON_RIGHT,
					XmNorientation, XmHORIZONTAL,
					NULL);
	XtManageChild(rc3);

	tmgridcol = CreateColorChoice(rc, "Color:", 0);
	tmgridlinew = CreatePanelChoice(rc, "Line width:",
					10,
			     "1", "2", "3", "4", "5", "6", "7", "8", "9", 0,
					0);
	tmgridlines = (Widget *) CreatePanelChoice(rc, "Line style:",
						   6,
						   "Solid line",
						   "Dotted line",
						   "Dashed line",
						   "Long Dashed",
						   "Dot-dashed",
						   NULL,
						   NULL);
	XtManageChild(rc);
	XtManageChild(fr);
	XtManageChild(rc2);

	tick_applyto = CreatePanelChoice(tickmark_panel, "Apply to:",
					 5,
					 "Current axis",
					 "All axes, current graph",
					 "Current axis, all graphs",
					 "All axes, all graphs",
					 NULL,
					 0);

	XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, tickmark_panel, NULL);

	CreateCommandButtons(tickmark_panel, 2, but1, label1);

	XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) accept_tickmark_proc, (XtPointer) 0);
	XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) tickmark_frame);


	XtManageChild(tickmark_panel);
    }
    XtRaise(tickmark_frame);
    update_tickmark_items(cg);
    unset_wait_cursor();
}