Beispiel #1
0
TEST_F(Directed, Add)
{
    repeat_n(100, [&](size_t i)
            {
            test_item_t* t = new test_item_t;
            t->data = i;
            AddQ(&q, t);
            ASSERT_EQ(i+1, size_(&q));
            });

    ASSERT_EQ(100, size_(&q));
    repeat_n(100, [&](size_t i){ DelQ(&q); });
    ASSERT_EQ(0, size_(&q));
}
Beispiel #2
0
void
EditorScreen::update_layout()
{
  Size size_(gui_manager->get_rect().get_width(),
             gui_manager->get_rect().get_height());

  minimap->set_rect(Rect(Vector2i(size_.width-244, size_.height-183), Size(244, 183)));

  if (minimap->is_visible())
    object_selector->set_rect(Rect(size_.width-244, 38, size_.width, size_.height - 183));
  else
    object_selector->set_rect(Rect(size_.width-244, 38, size_.width, size_.height));

  if (object_selector->is_visible())
  {
    viewport->set_rect(Rect(0, 38, size_.width - 244, size_.height));
    level_properties->set_rect(Rect(Vector2i(0,38), Size(size_.width-244, 258)));
  }
  else
  {
    viewport->set_rect(Rect(0, 38, size_.width, size_.height));
    level_properties->set_rect(Rect(Vector2i(0,38), Size(size_.width, 258)));
  }

  action_properties->set_rect(Rect(Vector2i(0, 38), Size(150, 240)));

  object_properties->set_rect(Rect(Vector2i(0, size_.height - object_properties->get_rect().get_height()),
                                   Size(object_properties->get_rect().get_width(),
                                        object_properties->get_rect().get_height())));

  file_load_dialog->set_rect(Rect(Vector2i(50, 50), Size(size_.width  - 100,
                                                         size_.height - 100)));
  file_save_dialog->set_rect(Rect(Vector2i(50, 50), Size(size_.width  - 100,
                                                         size_.height - 100)));
}
void generate_R_dendrogram(int * const merge, double * const height, int * const order, cluster_result & Z2, const int N) {
  // The array "nodes" is a union-find data structure for the cluster
  // identites (only needed for unsorted cluster_result input).
  union_find nodes(sorted ? 0 : N);
  if (!sorted) {
    std::stable_sort(Z2[0], Z2[N-1]);
  }

  t_index node1, node2;
  auto_array_ptr<t_index> node_size(N-1);

  for (t_index i=0; i<N-1; ++i) {
    // Get two data points whose clusters are merged in step i.
    // Find the cluster identifiers for these points.
    if (sorted) {
      node1 = Z2[i]->node1;
      node2 = Z2[i]->node2;
    }
    else {
      node1 = nodes.Find(Z2[i]->node1);
      node2 = nodes.Find(Z2[i]->node2);
      // Merge the nodes in the union-find data structure by making them
      // children of a new node.
      nodes.Union(node1, node2);
    }
    // Sort the nodes in the output array.
    if (node1>node2) {
      t_index tmp = node1;
      node1 = node2;
      node2 = tmp;
    }
    /* Conversion between labeling conventions.
       Input:  singleton nodes 0,...,N-1
               compound nodes  N,...,2N-2
       Output: singleton nodes -1,...,-N
               compound nodes  1,...,N
    */
    merge[i]     = (node1<N) ? -static_cast<int>(node1)-1
                              : static_cast<int>(node1)-N+1;
    merge[i+N-1] = (node2<N) ? -static_cast<int>(node2)-1
                              : static_cast<int>(node2)-N+1;
    height[i] = Z2[i]->dist;
    node_size[i] = size_(node1) + size_(node2);
  }

  order_nodes(N, merge, node_size, order);
}
Beispiel #4
0
TEST_F(Directed, PutGet)
{
    int i = 8;
    test_item_t t;
    t.data = i;
    AddQ(&q, &t);
    ASSERT_EQ(8, DelQ(&q)->data);
    ASSERT_EQ(0, size_(&q));
}
Beispiel #5
0
PingusMenu::PingusMenu() :
  is_init(),
  hint(),
  help(),
  text_scroll_offset(),
  background(),
  logo(),
  start_button(),
  quit_button(),
  editor_button(),
  contrib_button(),
  options_button()
{
  is_init = false;

  Size size_(Display::get_width(), Display::get_height());

  start_button = gui_manager->create<MenuButton>(
    this, Vector2i(size_.width/2 - 125,
                   size_.height/2 - 20),
    _("Story"),
    _("..:: Start the game ::.."));

  editor_button = gui_manager->create<MenuButton>(
    this, Vector2i(size_.width/2 + 125,
                   size_.height/2 - 20),
    _("Editor"),
    _("..:: Create your own levels ::.."));

  options_button = gui_manager->create<MenuButton>(
    this, Vector2i(size_.width/2 + 125,
                   size_.height/2 + 50),
    _("Options"),
    _("..:: Configure the game ::.."));

  contrib_button = gui_manager->create<MenuButton>(
    this, Vector2i(size_.width/2 - 125,
                   size_.height/2 + 50),
    _("Levelsets"),
    _("..:: Play User Built levels ::.."));

  quit_button = gui_manager->create<MenuButton>(
    this, Vector2i(size_.width/2,
                   size_.height/2 + 120),
    _("Exit"),
    _("..:: Bye, bye ::.."));

  logo = Sprite("core/misc/logo");

  create_background(Size(Display::get_width(), Display::get_height()));

  help = _("..:: Ctrl-g: mouse grab   ::   F10: fps counter   ::   F11: fullscreen   ::   F12: screenshot ::..");

  Sound::PingusSound::play_music("pingus-1.it");
}
Beispiel #6
0
void OOFImage3D::setSize(const Coord *sighs) {
  size_ = *sighs;
  if(sizeInPixels_ != size_){
    // We need to change the data spacing of the image object
    vtkImageChangeInformation *changer;
    double x_spacing, y_spacing, z_spacing;

    x_spacing = size_(0)/(double)sizeInPixels_(0);
    y_spacing = size_(1)/(double)sizeInPixels_(1);
    z_spacing = size_(2)/(double)sizeInPixels_(2);
    changer = vtkImageChangeInformation::New();
    changer->SetInputConnection(image->GetProducerPort());
    // TODO: check that all spacings are non-zero and throw error.
    if (!(x_spacing && y_spacing && z_spacing)) { cout << "zero spacing" << endl;}
    changer->SetOutputSpacing(x_spacing, y_spacing, z_spacing);
    image = changer->GetOutput();
    image->Update();
  }	


}
JNIEXPORT jint JNICALL
Java_com_h6ah4i_android_media_opensl_audiofx_OpenSLVisualizer_getCaptureSizeImplNative(JNIEnv *env, jclass clazz,
                                                                                       jlong handle,
                                                                                       jintArray size) noexcept
{
    if (!handle) {
        return OSLMP_RESULT_INVALID_HANDLE;
    }

    jint_array size_(env, size);

    if (!size_) {
        return OSLMP_RESULT_ERROR;
    }

    Holder *holder = Holder::fromJniHandle(handle);
    size_t value = 0;

    int result = holder->visualizer->getCaptureSize(&value);

    size_[0] = static_cast<jint>(value);

    return result;
}
Beispiel #8
0
 RANGES_CXX14_CONSTEXPR range_size_type_t<Rng> size()
     noexcept(noexcept(ranges::size(std::declval<Rng &>())))
 {
     return size_(ranges::size(this->base()));
 }
Beispiel #9
0
 constexpr range_size_type_t<Rng> size() const
     noexcept(noexcept(ranges::size(std::declval<Rng const &>())))
 {
     return size_(ranges::size(this->base()));
 }
Beispiel #10
0
// Draw the background and components
void
EditorScreen::draw(DrawingContext& gc)
{
  // Black out screen
  //gc.fill_screen(Color(255,0,255)); // FIXME: Could be removed for added speed
  gui_manager->draw(gc);

  if (show_help)
  {
    Size size_(640, 400);
    gc.draw_fillrect(Rect(gc.get_width()/2  - size_.width/2 - 2,
                          gc.get_height()/2 - size_.height/2 - 2,
                          gc.get_width()/2  + size_.width/2 + 2,
                          gc.get_height()/2 + size_.height/2 + 2),
                     Color(0,0,0));
    gc.draw_fillrect(Rect(gc.get_width()/2  - size_.width/2,
                          gc.get_height()/2 - size_.height/2,
                          gc.get_width()/2  + size_.width/2,
                          gc.get_height()/2 + size_.height/2),
                     Color(255,255,255));

    gc.print_center(Fonts::verdana11,
                    Vector2i(gc.get_width()/2,
                             gc.get_height()/2 - size_.height/2 + 12),
                    _("== Editor Help =="));

    int x = gc.get_width()/2 - size_.width/2 + 12;
    int y = gc.get_height()/2 - size_.height/2 + 36;
    gc.print_center(Fonts::verdana11, Vector2i(x + 75, y),
                    "A\n"
                    "Shift+A\n"
                    "PageUp, ], w\n"
                    "PageDown, [, s\n"
                    "Shift+PageUp\n"
                    "Shift+PageDown\n"
                    "R\n"
                    "Shift+R\n"
                    "G\n"
                    "Shift+G\n"
      );

    gc.print_left(Fonts::verdana11, Vector2i(x+150, y),
                  _("Select all\n"
                    "Clear Selection\n"
                    "Raise objects\n"
                    "Lower objects\n"
                    "Raise objects to top\n"
                    "Lower objects to bottom\n"
                    "Rotate 90 degree\n"
                    "Rotate 270 degree\n"
                    "Group selected objects\n"
                    "Ungroup selected objects\n"));

    x = int(gc.get_width()/2 + 12);
    y = int(gc.get_height()/2) - size_.height/2 + 36;
    gc.print_center(Fonts::verdana11, Vector2i(x + 50, y),
                    "F\n"
                    "Shift+F\n"
                    "Delete, Backspace\n"
                    "I, K, J, L\n"
                    "Shift+I, K, J, L\n"
                    "B, Shift+B\n"
                    "=, +, -\n");

    gc.print_left(Fonts::verdana11, Vector2i(x + 125, y),
                  _("Flip object horizontaly\n"
                    "Flip object vertically\n"
                    "Delete all marked objects\n"
                    "Move objects by one pixel\n"
                    "Move objects by 32 pixel\n"
                    "Toggle background color\n"
                    "Increase/lower repeat\n"));

    gc.print_left(Fonts::verdana11,
                  Vector2i(gc.get_width()/2 - size_.width/2 + 12,
                           gc.get_height()/2 - 10),
                  _("You should name your level files systematically, i.e. by their theme, "
                    "their number and your nickname:\n\n"
                    "     <levelname><number>-<creator>.pingus\n\n"
                    "So if you create your second level with a stone theme, call it: "
                    "stone2-yourname.pingus\n\n"
                    "When you have created a level and want to have it included "
                    "in the game mail it to:\n\n"
                    "     [email protected]\n\n"
                    "Only levels published under the GPL are allowed into the game. The editor "
                    "automatically inserts a reference \n"
                    "to the GPL, if you want to have your level under a different license, you "
                    "have to change that reference.\n"
                    ));
  }
}
Beispiel #11
0
Datei: mar.c Projekt: marayl/aug
static aug_result
run_BIN_(int argc, char* argv[], const char* archivename)
{
    aug_mpool* mpool;
    int flags = 0;
    mode_t mode = 0;

    aug_mar* mar;
    int ch;

    switch (options_ & (READOPT_ | WRITEOPT_)) {
    case READOPT_:
        flags = AUG_RDONLY;
        break;
    case WRITEOPT_:
        flags = AUG_WRONLY;
        break;
    case READOPT_ | WRITEOPT_:
        flags = AUG_RDWR;
        break;
    }

    if (options_ & CREATEOPT_) {
        flags |= AUG_CREAT;
        mode = 0666;
    }

    mpool = aug_getmpool(aug_tlx);
    mar = aug_openmar_BIN(mpool, archivename, flags, mode);
    aug_release(mpool);

    if (!mar) {
        aug_perrinfo(aug_tlx, "aug_openmar() failed", NULL);
        return -1;
    }

    while (-1 != (ch = aug_getopt(argc, argv, OPTIONS_)))
        switch (ch) {
        case 'c':
            if (clear_(mar) < 0) {
                aug_perrinfo(aug_tlx, "failed to " CLEARTEXT_, NULL);
                goto fail;
            }
            break;
        case 'd':
            if (del_(mar, aug_optarg) < 0) {
                aug_perrinfo(aug_tlx, "failed to " DELTEXT_, NULL);
                goto fail;
            }
            break;
        case 'f':
            break;
        case 'g':
            if (get_(mar, aug_optarg) < 0) {
                aug_perrinfo(aug_tlx, "failed to " GETTEXT_, NULL);
                goto fail;
            }
            break;
        case 'i':
            if (insert_BIN_(mar, aug_optarg) < 0) {
                aug_perrinfo(aug_tlx, "failed to " INSERTTEXT_, NULL);
                goto fail;
            }
            break;
        case 'l':
            if (names_(mar) < 0) {
                aug_perrinfo(aug_tlx, "failed to " NAMESTEXT_, NULL);
                goto fail;
            }
            break;
        case 'n':
            size_(mar);
            break;
        case 'o':
            if (aug_compactmar(mar) < 0) {
                aug_perrinfo(aug_tlx, "failed to " COMPACTTEXT_, NULL);
                goto fail;
            }
            break;
        case 'p':
            if (put_BIN_(mar, aug_optarg) < 0) {
                aug_perrinfo(aug_tlx, "failed to " PUTTEXT_, NULL);
                goto fail;
            }
            break;
        case 't':
            if (list_(mar) < 0) {
                aug_perrinfo(aug_tlx, "failed to " LISTTEXT_, NULL);
                goto fail;
            }
            break;
        case 'x':
            if (extract_(mar, aug_optarg) < 0) {
                aug_perrinfo(aug_tlx, "failed to " EXTRACTTEXT_, NULL);
                goto fail;
            }
            break;
        case 'z':
            if (zero_(mar) < 0) {
                aug_perrinfo(aug_tlx, "failed to " ZEROTEXT_, NULL);
                goto fail;
            }
            break;
        case 'h':
        case '?':
        default:
            fprintf(stderr, "unexpected option [-%c]\n", aug_optopt);
            goto fail;
        }

    aug_release(mar);
    return 0;

 fail:
    aug_release(mar);
    return -1;
}
Beispiel #12
0
 size_type size() const
 {
     // Non-virtual interface
     return size_();
 }
Beispiel #13
0
 RANGES_CXX14_CONSTEXPR
 range_size_type_t<Rng> size()
 {
     return size_();
 }