Пример #1
0
unsigned char is_valid_prev_charge (PREV_CHARGE *prev_chg, int curr_table, int curr_prod)
{

    switch (curr_table)
    {
        case PAYMENTS_TABLE:
        /* If is a valid prev_charge to display, return its display type for formatting; otherwise, no display */
            if ((prev_chg->is_formatted == FALSE) &&
                (prev_chg->type_code == BMF_TYPE) &&
                (to_display(prev_chg->type_code, prev_chg->trans_code)) &&
                prev_chg->prorate_code != BMF_CREDIT_NOTE)
                /* if a valid type, return its display type for formatting */
                return (lookup_display_type (prev_chg->amount, prev_chg->type_code, prev_chg->trans_code, prev_chg->billing_category, prev_chg->billing_level));
            else
                return (0);     /* if not a valid type, no display */
            break;

        case ADJUSTMENTS_TABLE:
        /* If is a valid prev_charge to display, return its display type for formatting; otherwise, no display */
            if ((prev_chg->is_formatted == FALSE) &&
                (prev_chg->type_code == ADJ_TYPE) &&
                (to_display(prev_chg->type_code, prev_chg->trans_code)))
                /* if a valid type, return its display type for formatting */
                return (lookup_display_type (prev_chg->amount, prev_chg->type_code, prev_chg->trans_code, prev_chg->billing_category, prev_chg->billing_level));
            else
                return (0);     /* if not a valid type, no display */
            break;

     }
    return 0;   /* if switch falls through, no display */
}
Пример #2
0
void Main_win::inv_clicked()
{
  Matrix m(mat_dim_.first, mat_dim_.second);
  read_matrix(m);

  math_->inv(m);

  to_display("(");
  to_display(dis_char_.first.at(dis_char_.second));
  to_display(")inv");
}
Пример #3
0
void Main_win::trans_clicked()
{
  Matrix m(mat_dim_.first, mat_dim_.second);
  read_matrix(m);

  math_->trans(m);

  to_display("(");
  to_display(dis_char_.first.at(dis_char_.second));
  to_display(")trans");
}
Пример #4
0
void Main_win::save_clicked()
{
  try
  {
    QFileDialog fd;
    fd.setDefaultSuffix(".mat"); // not working under linux?!

    QString q_form = fd.getSaveFileName(this, tr("Save Matrix"));

    std::ofstream target(q_form.toStdString(), std::ios::trunc);

    if(target.fail()) throw std::ios_base::failure("cannot save matrix");

    for(int i = 0; i < mat_dim_.first; ++i)
    {
      for(int j = 0; j < mat_dim_.second; ++j)
      {
        auto item = qobject_cast< Field* >(ui_->mat_layout->itemAtPosition(i,
                                           j)->widget());
        if(item)
          target << item->get_text() << " ";
      }
      target << "\n";
    }

    target.close();
  }
  catch(std::exception& e)
  {
    to_display(e.what());
  }
}
Пример #5
0
void Main_win::sub_clicked()
{
  Matrix m(mat_dim_.first, mat_dim_.second);
  read_matrix(m);

  try
  {
    math_->sub(m);

    to_display(next_display_char() + " - ");
  }
  catch(std::exception& e)
  {
    to_display(e.what());
  }
}
Пример #6
0
void Main_win::load_clicked()
{
  try
  {
    QString q_form = QFileDialog::getOpenFileName(this, tr("Load Matrix"));

    std::ifstream f;
    f.open(q_form.toStdString(), std::ios_base::in);

    if(f.is_open())
    {
      int row = 0;
      int col = 0;
      char c = 0;
      bool flag = true;

      while(f.get(c))
      {
        if(flag && (c == ' '))
          col++;
        if(c == '\n')
        {
          row++;
          flag = false;
        }
      }

      f.clear();
      f.seekg(0, f.beg);

      std::istream_iterator<double> ii{f};
      std::istream_iterator<double> eos{};
      std::vector<double> v{ii, eos};

      f.close();

      remove_matrix();

      build_matrix(row, col);

      mat_dim_.first = row;
      mat_dim_.second = col;

      mat_dim_tmp_.first = row;
      mat_dim_tmp_.second = col;

      display_matrix(row, col, v);
    }
    else throw std::ios_base::failure("cannot open file");
  }
  catch(std::exception& e)
  {
    e.what();
    to_display(e.what());
  }
}
Пример #7
0
void Main_win::det_clicked()
{
  try
  {
    Matrix m(mat_dim_.first, mat_dim_.second);
    read_matrix(m);

    math_->det(m);

    to_display("(");
    to_display(dis_char_.first.at(dis_char_.second));
    to_display(")det");
  }
  catch(std::exception& e)
  {
    reset_display();
    to_display(e.what());
  }
}
Пример #8
0
void Main_win::set_x_clicked()
{
  if(mat_dim_.second == 1)
    read_matrix(x_);
  else
  {
    reset_display();
    to_display("x is vector: set col-dim to 1");
  }

  x_set_ = true;
}
Пример #9
0
void Main_win::solve_clicked()
{
  try
  {
    if(A_set_ && b_set_)
    {
      math_->solve(A_, b_);

      reset_display();
      to_display("x = least-squares solution");
    }
    else
    {
      reset_display();
      to_display("first set A and b");
    }
  }
  catch(std::exception& e)
  {
    reset_display();
    to_display(e.what());
  }
}
Пример #10
0
void Main_win::dot_clicked()
{
  try
  {
    if(x_set_ && b_set_)
    {
      math_->dot(x_, b_);

      reset_display();
      to_display("< x , b > = a");
    }
    else
    {
      reset_display();
      to_display("first set x and b");
    }
  }
  catch(std::exception& e)
  {
    reset_display();
    to_display(e.what());
  }
}
void ChangeDisplay::processMessage( const ChangedSceneConstPtr& scene )
{
  initMessageProcessing(scene);

  addSimpleChanges(scene->removed, Change::REMOVE);
  addSimpleChanges(scene->added, Change::ADD);
  addSimpleChanges(scene->preserved, Change::PRESERVE);

  addMoveChanges(scene->moved);

  sensor_msgs::PointCloud2Ptr to_display(new sensor_msgs::PointCloud2());
  pcl::toROSMsg(display_cloud, *to_display);

  to_display->header = scene->header;

  point_cloud_common_->addMessage(to_display);
}