long fx_disp_lookup_window::on_cmd_replace_comp(FXObject *, FXSelector, void *)
{
    const int i = selected_component;
    disp_lookup *lookup = &disp->disp.lookup;
    disp_t *new_disp = ui_choose_dispersion(this);
    if (!new_disp) return 1;
    disp_free(lookup->component[i].disp);
    lookup->component[i].disp = new_disp;
    FXTextField *tf = (FXTextField *) matrix->childAtRowCol(i + 1, 1);
    tf->setText(CSTR(new_disp->name));
    return 1;
}
Exemple #2
0
long
fit_window::on_cmd_param_change(FXObject *_txt, FXSelector, void*)
{
  FXTextField *txt = (FXTextField *) _txt;
  param_info* p = (param_info*) txt->getUserData();
  FXString vstr = txt->getText();
  double new_val = strtod (vstr.text(), NULL);
  unsigned k = this->get_parameter_index(p);
  m_fit->set_parameter_value(k, new_val);
  if (m_canvas) m_canvas->set_dirty(true);
  return 1;
}
void fx_disp_fb_window::add_dispersion_element()
{
    int n = disp->disp.fb.n;
    disp_add_osc(disp);
    FXButton *db = new FXButton(matrix, "", regressProApp()->delete_icon, this, ID_DISP_ELEMENT_DELETE + n, FRAME_SUNKEN);
    db->create();
    for (int j = 3*n; j < 3*(n+1); j++) {
        FXTextField *tf = create_textfield(matrix, this, ID_PARAM_0 + j + 2);
        tf->create();
    }
    matrix->childAtRowCol(1, 0)->enable();
    vframe->recalc();
}
Exemple #4
0
long
fit_panel::on_update_param(FXObject *_txt, FXSelector, void*)
{
    FXTextField *txt = (FXTextField *) _txt;
    param_info* p = (param_info*) txt->getUserData();
    if(p->is_dirty) {
        unsigned k = this->get_parameter_index(p);
        FXString s = FXStringFormat("%g", m_fit->get_parameter_value(k));
        txt->setText(s, false);
        p->is_dirty = false;
        return 1;
    }
    return 0;
}
void fx_disp_window::setup_name()
{
    regress_pro *app = (regress_pro *) getApp();

    FXHorizontalFrame *modelfm = new FXHorizontalFrame(this, LAYOUT_FILL_X|FRAME_GROOVE, 0,0,0,0, 0,0,0,0, 0,0);
    FXString model_name(disp->dclass->full_name);
    model_name.append(" Model");
    FXLabel *model_label = new FXLabel(modelfm, model_name, NULL, LABEL_NORMAL|LAYOUT_FILL_X, 0, 0, 0, 0, 2*DEFAULT_PAD, 2*DEFAULT_PAD, 3*DEFAULT_PAD, 3*DEFAULT_PAD);
    model_label->setFont(&app->big_web_font);
    model_label->setTextColor(app->blue_web);
    model_label->setBackColor(FXRGB(255, 206, 91));

    FXHorizontalFrame *namehf = new FXHorizontalFrame(this, LAYOUT_FILL_X);
    new FXLabel(namehf, "Name ");
    FXTextField *tf = new FXTextField(namehf, 24, this, ID_NAME, FRAME_SUNKEN);
    tf->setText(CSTR(disp->name));
}
Exemple #6
0
void fit_panel::setup()
{
    param_matrix = new FXMatrix(scroll_window, 2, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_Y|MATRIX_BY_COLUMNS, 0, 0, 0, 0, DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, 1, 1);

    new FXLabel(param_matrix, "Range");
    m_wl_entry = new FXTextField(param_matrix, 10, this, ID_SPECTR_RANGE, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_ROW);

    config_spectral_range();

    m_parameters.resize(m_fit->parameters_number());

    Str pname;
    FXString label_text;
    int current_layer = 0;
    for(unsigned k = 0; k < m_parameters.size(); k++) {
        param_info* p = this->get_parameter_pointer(k);
        m_fit->get_parameter(k, &p->fp);

        if(p->fp.id == PID_LAYER_N && p->fp.layer_nb != current_layer) {
            current_layer = p->fp.layer_nb;
            label_text.format("Layer %i", current_layer);
            FXLabel *lab = new FXLabel(param_matrix, label_text);
            lab->setFont(&regressProApp()->bold_font);
            new FXLabel(param_matrix, "");
        }

        get_param_name(&p->fp, pname.str());
        FXString fxpname((const FXchar *) pname.cstr());
        FXCheckButton* bt = new FXCheckButton(param_matrix, fxpname, this, ID_PARAM_SELECT);
        FXTextField* tf = new fx_numeric_field(param_matrix, 10, this, ID_PARAM_VALUE, FRAME_SUNKEN|FRAME_THICK|TEXTFIELD_REAL|LAYOUT_FILL_ROW);

        tf->setUserData(p);
        bt->setUserData(p);

        p->text_field = tf;
        p->selected = false;
        p->is_dirty = true;
    }

    m_undo_manager.clear();

    m_canvas = new plot_canvas(this, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y);
    m_fit->config_plot(m_canvas);
}
Exemple #7
0
long AliasDialog::onAdd(FXObject*, FXSelector, void*)
{
    FXDialogBox aliasEdit(this, _("Alias edit"), DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    FXVerticalFrame *contents = new FXVerticalFrame(&aliasEdit, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0);
    FXMatrix *matrix = new FXMatrix(contents, 2, MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
    new FXLabel(matrix, _("Alias:"), NULL, JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
    FXTextField *alias = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
    new FXLabel(matrix, _("Command:"), NULL, JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
    FXTextField *command = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);

    FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH);
    new dxEXButton(buttonframe, _("&Cancel"), NULL, &aliasEdit, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2);
    new dxEXButton(buttonframe, _("&OK"), NULL, &aliasEdit, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2);

    if(aliasEdit.execute(PLACEMENT_OWNER))
    {
        if(alias->getText().empty() || command->getText().empty())
            return 1;
        if(alias->getText()[0] != '/')
        {
            dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Alias command has to start with '/'"));
            return 1;
        }
        if(alias->getText().contains(' '))
        {
            dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Alias command cann't contain space"));
            return 1;
        }
        if(commandExist(alias->getText()))
        {
            dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Command '%s' already exist"), alias->getText().text());
            return 1;
        }
        m_aliases.insert(StringPair(alias->getText(), command->getText()));
        updateTable();
    }
    return 1;
}
Exemple #8
0
fit_window::fit_window(fit_manager* fit, FXApp* a,const FXString& name,FXIcon *ic,FXIcon *mi,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs)
  : FXMainWindow(a, "Dispersion Fit", ic, mi, opts, x, y, w, h, pl, pr, pt, pb, hs, vs),
    m_canvas(0), m_fit(fit)
{
  // Menubar
  menubar = new FXMenuBar(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
  statusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_RAISED|STATUSBAR_WITH_DRAGCORNER);

  // fit menu
  fitmenu = new FXMenuPane(this);
  new FXMenuCommand(fitmenu, "&Run", NULL, this, ID_RUN_FIT);
  new FXMenuTitle(menubar, "&Fit", NULL, fitmenu);

  // plot menu
  plotmenu = new FXMenuPane(this);
  new FXMenuCommand(plotmenu, "&Auto Scale", NULL, this, ID_PLOT_SCALE);
  new FXMenuTitle(menubar, "&Plot", NULL, plotmenu);

  FXHorizontalFrame *mf = new FXHorizontalFrame(this, LAYOUT_FILL_X|LAYOUT_FILL_Y);
  FXScrollWindow *iw = new FXScrollWindow(mf, VSCROLLER_ALWAYS | HSCROLLING_OFF | LAYOUT_FILL_Y);

  FXMatrix *matrix = new FXMatrix(iw, 2, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_Y|MATRIX_BY_COLUMNS, 0, 0, 0, 0, DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, 1, 1);

  new FXLabel(matrix, "Range");
  m_wl_entry = new FXTextField(matrix, 10, this, ID_SPECTR_RANGE, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_ROW);

  {
    double wls, wle, wld;
    m_fit->get_sampling(wls, wle, wld);

    if (wld == 0.0)
      m_wl_entry->setText(FXStringFormat("%.3g-%.3g", wls, wle));
    else
      m_wl_entry->setText(FXStringFormat("%.3g-%.3g,%g", wls, wle, wld));
  }

  m_parameters.resize(m_fit->parameters_number());

  m_bold_font = new FXFont(getApp(), "helvetica", 9, FXFont::Bold, FXFont::Italic);

  Str pname;
  FXString label_text;
  int current_layer = 0;
  for (unsigned k = 0; k < m_parameters.size(); k++)
    {
      param_info* p = this->get_parameter_pointer(k);
      m_fit->get_parameter(k, &p->fp);

      if (p->fp.id == PID_LAYER_N && p->fp.layer_nb != current_layer)
        {
          current_layer = p->fp.layer_nb;
          label_text.format("Layer %i", current_layer);
          FXLabel *lab = new FXLabel(matrix, label_text);
	  lab->setFont(m_bold_font);
          new FXLabel(matrix, "");
        }

      get_param_name(&p->fp, pname.str());
      FXString fxpname((const FXchar *) pname.cstr());
      FXCheckButton* bt = new FXCheckButton(matrix, fxpname, this, ID_PARAM_SELECT);
      FXTextField* tf = new fx_numeric_field(matrix, 10, this, ID_PARAM_VALUE, FRAME_SUNKEN|FRAME_THICK|TEXTFIELD_REAL|LAYOUT_FILL_ROW);

      tf->setUserData(p);
      bt->setUserData(p);

      p->text_field = tf;
      p->selected = false;
      p->is_dirty = true;
    }

  m_canvas = new plot_canvas(mf, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y);

  m_fit->config_plot(m_canvas);
}