Ejemplo n.º 1
0
octave_value OR_StructMatrix::to_octave()
{
  int i, row_index, column_index;
  VALUE row, cell;
  VALUE cells = rb_iv_get(ruby_val, "@cells");
  VALUE names = rb_iv_get(ruby_val, "@names");
  int number_of_keys = RARRAY(names)->len;
  int number_of_rows = FIX2INT(rb_iv_get(ruby_val, "@m"));
  int number_of_columns = FIX2INT(rb_iv_get(ruby_val, "@n"));

  string_vector keys = string_vector();
  for (i = 0; i < number_of_keys; i++) {
    keys.append(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr));
  }
  
  Octave_map struct_matrix = Octave_map(dim_vector(number_of_rows, number_of_columns), Cell(keys));
  for (row_index = 0; row_index < number_of_rows; row_index++) {
    row = RARRAY(cells)->ptr[row_index];
  
    for (column_index = 0; column_index < number_of_columns; column_index++) {
      cell = RARRAY(row)->ptr[column_index];
      
      for (i = 0; i < number_of_keys; i++) {
        struct_matrix.contents(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr))(row_index, column_index) = OR_Variable(rb_hash_aref(cell, rb_str_new2(RSTRING(RARRAY(names)->ptr[i])->ptr))).to_octave();
      }
    }
  }
  
  return struct_matrix;
}
Ejemplo n.º 2
0
void ListBoxControl::itemSelectionChanged (void)
{
  if (! m_blockCallback)
    {
      QListWidget* list = qWidget<QListWidget> ();

      QModelIndexList l = list->selectionModel ()->selectedIndexes ();
      Matrix value (dim_vector (1, l.size ()));
      int i = 0;

      foreach (const QModelIndex& idx, l)
       value(i++) = (idx.row () + 1);

      gh_manager::post_set (m_handle, "value", octave_value (value), false);
      gh_manager::post_callback (m_handle, "callback");
    }