Example #1
0
TEST(Test04, MembershipTests)
{
    
    {
        int x[100];
        Set universal;
        createEmptySet(&universal);

        for (int i = 0; i < 100; i++)
        {
            insertSet(&universal, i);
            x[i] = i;
        }

        Set s;
        createCopySet(&s, &universal);

        for (int i = 0; i < 50; i++)
        {
            /* choose a random element in array x */
            int k = rand() % (100 - i);
            int val = x[i];

            /* remove that random value from x by copying the last element into position k */
            x[k] = x[100 - i - 1];

            ASSERT_TRUE(isMemberSet(&s, val));

            removeSet(&s, val);

            ASSERT_FALSE(isMemberSet(&s, val));
        }
    }
}
StatusSetDialog::StatusSetDialog( QWidget * parent )
: QDialog( parent )
{
	setupUi( this );
	
	connect( mAddButton, SIGNAL( clicked() ),  SLOT( addSet() ) );
	connect( mEditButton, SIGNAL( clicked() ), SLOT( editSet() ) );
	connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeSet() ) );
	
	connect( mSetList, SIGNAL( currentTextChanged( const QString & ) ), SLOT( setChanged( const QString & ) ) );
	
	updateSets();
}
END_BUILDEREXT_SIGNATURE


// =====================================================================
// =====================================================================


CSVObsParamsWidget::CSVObsParamsWidget(): openfluid::builderext::PluggableParameterizationExtension(),
  ui(new Ui::CSVObsParamsWidget)
{
  ui->setupUi(this);
  setAutoFillBackground(true);

  ui->AddFormatButton->setIcon(openfluid::ui::common::getIcon("add","/ui/common"));
  ui->AddFormatButton->setIconSize(QSize(16,16));

  ui->EditFormatButton->setIcon(openfluid::ui::common::getIcon("modify","/ui/common"));
  ui->EditFormatButton->setIconSize(QSize(16,16));

  ui->RemoveFormatButton->setIcon(openfluid::ui::common::getIcon("remove","/ui/common"));
  ui->RemoveFormatButton->setIconSize(QSize(16,16));

  ui->AddSetButton->setIcon(openfluid::ui::common::getIcon("add","/ui/common"));
  ui->AddSetButton->setIconSize(QSize(16,16));

  ui->EditSetButton->setIcon(openfluid::ui::common::getIcon("modify","/ui/common"));
  ui->EditSetButton->setIconSize(QSize(16,16));

  ui->RemoveSetButton->setIcon(openfluid::ui::common::getIcon("remove","/ui/common"));
  ui->RemoveSetButton->setIconSize(QSize(16,16));

  ui->AutoButton->setIcon(openfluid::ui::common::getIcon("magic","/ui/common"));
  ui->AutoButton->setIconSize(QSize(16,16));

  connect(ui->AddFormatButton,SIGNAL(clicked()),this,SLOT(addFormat()));
  connect(ui->EditFormatButton,SIGNAL(clicked()),this,SLOT(editFormat()));
  connect(ui->FormatsTableWidget,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(editFormat()));
  connect(ui->RemoveFormatButton,SIGNAL(clicked()),this,SLOT(removeFormat()));
  connect(ui->AddSetButton,SIGNAL(clicked()),this,SLOT(addSet()));
  connect(ui->EditSetButton,SIGNAL(clicked()),this,SLOT(editSet()));
  connect(ui->SetsTableWidget,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(editSet()));
  connect(ui->RemoveSetButton,SIGNAL(clicked()),this,SLOT(removeSet()));
  connect(ui->AutoButton,SIGNAL(clicked()),this,SLOT(generateAutomaticFormatAndSets()));
}
StitchLibraryUi::StitchLibraryUi(QWidget* parent)
    : QDialog(parent), ui(new Ui::StitchLibraryDialog)
{
    ui->setupUi(this);

    ui->stitchSource->addItems(StitchLibrary::inst()->stitchSetList());

    StitchSet* master = StitchLibrary::inst()->masterStitchSet();

    mProxyModel = new QSortFilterProxyModel(this);

    mProxyModel->setSourceModel(master);
    mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);

    ui->listView->setModel(mProxyModel);
    ui->listView->setSortingEnabled(true);

    StitchLibraryDelegate *delegate = new StitchLibraryDelegate(ui->listView);
    ui->listView->setItemDelegate(delegate);

    setDialogSize();
    ui->listView->horizontalHeader()->setClickable(true);
    ui->listView->horizontalHeader()->setSortIndicatorShown(true);

    //TODO: Wrong Side.
    ui->listView->hideColumn(4);

    ui->propertiesBox->setVisible(false);
    connect(ui->moreBttn, SIGNAL(clicked()), SLOT(hideProperties()));
    connect(ui->printSet, SIGNAL(clicked()), SLOT(printStitchSet()));

    connect(ui->addStitch, SIGNAL(clicked()), SLOT(addStitch()));
    connect(ui->removeStitch, SIGNAL(clicked()), SLOT(removeStitch()));
    connect(ui->addSelected, SIGNAL(clicked()), SLOT(addSelected()));

    connect(ui->createSet, SIGNAL(clicked()), SLOT(createSet()));
    connect(ui->removeSet, SIGNAL(clicked()), SLOT(removeSet()));

    connect(ui->importSet, SIGNAL(clicked()), SLOT(importSet()));
    connect(ui->exportSet, SIGNAL(clicked()), SLOT(exportSet()));

    connect(ui->setName, SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->author,  SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->email,   SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->org,     SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->url,     SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));

    setupPropertiesBox();
    
    connect(ui->stitchSource, SIGNAL(currentIndexChanged(QString)), SLOT(changeStitchSet(QString)));

    connect(ui->resetLibrary, SIGNAL(clicked()), SLOT(resetLibrary()));
    connect(ui->icons, SIGNAL(clicked()), SLOT(iconDialog()));

    connect(ui->listView->horizontalHeader(),
            SIGNAL(sectionClicked(int)), SLOT(updateRowSizes()));

    connect(ui->stitchFilter, SIGNAL(textChanged(QString)), SLOT(filterStitchList(QString)));
    connect(ui->clearBttn, SIGNAL(clicked()), SLOT(clearStitchFilter()));

    setButtonStates(master);
}
Example #5
0
/* =====================================================================
 * set initial values for the next level
 * =====================================================================*/
static void maze_next_level() {
  GdkPixbuf *pixmap = NULL;

  maze_destroy_all_items();
  gc_bar_set_level(gcomprisBoard);
  setlevelproperties();

  mapActive = FALSE;

  ind = 0;
  gamewon = FALSE;
  initMaze();
  generateMaze((g_random_int()%breedte),(g_random_int()%hoogte));
  removeSet();
  /* Try the next level */
  maze_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
  draw_background(wallgroup);

  if(modeIsInvisible) {
    g_object_set (wallgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
  }

  /* make a new group for the items */
  begin=g_random_int()%hoogte;
  end=g_random_int()%hoogte;

  /* Draw the tux */
  RsvgHandle *svg_handle = gc_rsvg_load("maze/tux_top_south.svg");
  tuxitem = goo_canvas_svg_new (tuxgroup, svg_handle,
				NULL);
  g_object_unref (svg_handle);

  goo_canvas_item_translate(tuxgroup,
			    cellsize*(0)-breedte + board_border_x,
			    cellsize*(begin)-hoogte + board_border_y);

  g_signal_connect(tuxitem,
		   "button_press_event",
		   (GCallback) tux_event, NULL);

  if(run_fast_possible) {
	  /* Load the tux shoes */
	  svg_handle = gc_rsvg_load("maze/tux_shoes_top_south.svgz");
	  tuxshoes = goo_canvas_svg_new (tuxgroup, svg_handle,
					"pointer-events", GOO_CANVAS_EVENTS_NONE, NULL);
	  g_object_unref (svg_handle);

	  /* Load fast-mode switch button */
	  svg_handle = gc_rsvg_load("maze/fast-mode-button.svgz");
	  fast_mode_button = goo_canvas_svg_new (boardRootItem, svg_handle,
					NULL);
	  g_object_unref (svg_handle);
	  goo_canvas_item_translate(fast_mode_button, 10, 10);
	  g_signal_connect(fast_mode_button,
			   "button_press_event",
			   (GCallback) on_fast_mode_button_press, NULL);
	  gc_item_focus_init(fast_mode_button, NULL);
  }

  /* Draw the target */
  pixmap = gc_pixmap_load("maze/door.png");
  if(pixmap)
    {
      draw_image(mazegroup,breedte-1,end,pixmap);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif
    }

  position[ind][0]=0;
  position[ind][1]=begin;
  Maze[0][begin]=Maze[0][begin]+SET;
  viewing_direction=EAST;
  threeDactive=FALSE;

  if(run_fast_possible) {
	  // run_fast-mode should be initialized at every level, whether TRUE or FALSE
	  if (gcomprisBoard->level < 14) set_run_fast(FALSE);
	  if (gcomprisBoard->level >= 14) set_run_fast(TRUE);
  }

  update_tux(viewing_direction);

  if(!modeIs2D)
    threeDdisplay();

}
Example #6
0
void specialCaseTests(void) {
	Set empty;
	Set universal;
	int i;
	Set s;
	Set r;
	
	createEmptySet(&empty);
	createEmptySet(&universal);
	createEmptySet(&r);
	for (i = 0; i < maximum_set_size; i += 1) {
	  insertSet(&universal, i);
	}
	checkCase(&subtractFromSet, &universal, &universal, &empty);
	checkCase(&unionInSet, &universal, &universal, &universal);
	checkCase(&intersectFromSet, &universal, &universal, &universal);
	checkCase(&intersectFromSet, &universal, &empty, &empty);
	checkCase(&intersectFromSet, &empty, &universal, &empty);
	checkCase(&unionInSet, &universal, &empty, &universal);
	checkCase(&unionInSet, &empty, &universal, &universal);
	checkCase(&unionInSet, &empty, &empty, &empty);
	checkCase(&subtractFromSet, &empty, &empty, &empty);
	checkCase(&intersectFromSet, &empty, &empty, &empty);
	
	createEmptySet(&s);
	assert(isEmptySet(&s));
	for (i = 0; i < 10; i += 1) {
		insertSet(&s, i);
	}
	assert(s.len == 10);
	for (i = 0; i < 10; i += 1) {
	  assert(isMemberSet(&s, i));
	}
	for (i = 0; i < 10; i += 1) {
	  removeSet(&s, i);
	  removeSet(&s, i);
	  assert(s.len == 9 - i); 
	}
	assert(isEmptySet(&s));
	for (i = 0; i < number_of_tests; i += 1) {
	  randomSet(&s);
	  assert(isSubsetOf(&empty, &s));
	  assert(!isSubsetOf(&s, &empty));
	  assert(isSubsetOf(&s, &universal));
	  assert(!isSubsetOf(&universal, &s));

		checkCase(&intersectFromSet, &empty, &s, &empty);
		checkCase(&intersectFromSet, &s, &empty, &empty);
		checkCase(&intersectFromSet, &universal, &s, &s);
		checkCase(&intersectFromSet, &s, &universal, &s);

		checkCase(&unionInSet, &universal, &s, &universal);
		checkCase(&unionInSet, &s, &universal, &universal);

		checkCase(&subtractFromSet, &s, &empty, &s);
		
		assignSet(&r, &universal);
		subtractFromSet(&r, &s); // r = u - s;
		checkCase(&subtractFromSet, &universal, &r, &s); // (u - (u - s) == s)
		checkCase(&unionInSet, &s, &r, &universal); // s + (u - s) == u
		checkCase(&unionInSet, &r, &s, &universal); // (u - s) + s == u
	}
	printf("The special case tests have been passed\n"); 
	destroySet(&empty);
	destroySet(&universal);
	destroySet(&s);
	destroySet(&r);
}
Example #7
0
TEST(Test05, SpecialCaseTests)
{
    
    {
        Set empty;
        Set universal;
        Set s;
        Set r;
        int i;

        createEmptySet(&empty);
        createEmptySet(&universal);
        createEmptySet(&r);

        for (i = 0; i < MAX_SET_SIZE; i++)
        {
            insertSet(&universal, i);
        }

        ASSERT_TRUE(checkCaseNew(&subtractFromSet, &universal, &universal, &empty));
        ASSERT_TRUE(checkCaseNew(&unionInSet, &universal, &universal, &universal));
        ASSERT_TRUE(checkCaseNew(&intersectFromSet, &universal, &universal, &universal));
        ASSERT_TRUE(checkCaseNew(&intersectFromSet, &universal, &empty, &empty));
        ASSERT_TRUE(checkCaseNew(&intersectFromSet, &empty, &universal, &empty));
        ASSERT_TRUE(checkCaseNew(&unionInSet, &universal, &empty, &universal));
        ASSERT_TRUE(checkCaseNew(&unionInSet, &empty, &universal, &universal));
        ASSERT_TRUE(checkCaseNew(&unionInSet, &empty, &empty, &empty));
        ASSERT_TRUE(checkCaseNew(&subtractFromSet, &empty, &empty, &empty));
        ASSERT_TRUE(checkCaseNew(&intersectFromSet, &empty, &empty, &empty));

        createEmptySet(&s);
        ASSERT_TRUE(isEmptySet(&s));

        for (i = 0; i < 10; i++)
        {
            insertSet(&s, i);
        }

        ASSERT_TRUE(s.len == 10);

        for (i = 0; i < 10; i++)
        {
            ASSERT_TRUE(isMemberSet(&s, i));
        }

        for (i = 0; i < 10; i++)
        {
            removeSet(&s, i);
            removeSet(&s, i);
            ASSERT_TRUE(s.len == 9 - i);
        }

        ASSERT_TRUE(isEmptySet(&s));

        for (i = 0; i < NUM_TESTS; i++)
        {
            randomSet(&s);
            ASSERT_TRUE(isSubsetOf(&empty, &s));
            ASSERT_FALSE(isSubsetOf(&s, &empty));
            ASSERT_TRUE(isSubsetOf(&s, &universal));
            ASSERT_FALSE(isSubsetOf(&universal, &s));

            ASSERT_TRUE(checkCaseNew(&intersectFromSet, &empty, &s, &empty));
            ASSERT_TRUE(checkCaseNew(&intersectFromSet, &s, &empty, &empty));
            ASSERT_TRUE(checkCaseNew(&intersectFromSet, &universal, &s, &s));
            ASSERT_TRUE(checkCaseNew(&intersectFromSet, &s, &universal, &s));

            ASSERT_TRUE(checkCaseNew(&unionInSet, &universal, &s, &universal));
            ASSERT_TRUE(checkCaseNew(&unionInSet, &s, &universal, &universal));

            ASSERT_TRUE(checkCaseNew(&subtractFromSet, &s, &empty, &s));

            assignSet(&r, &universal);
            subtractFromSet(&r, &s);
            ASSERT_TRUE(checkCaseNew(&subtractFromSet, &universal, &r, &s));
            ASSERT_TRUE(checkCaseNew(&unionInSet, &s, &r, &universal));
            ASSERT_TRUE(checkCaseNew(&unionInSet, &r, &s, &universal));
        }

        destroySet(&empty);
        destroySet(&universal);
        destroySet(&s);
        destroySet(&r);
    }
}