예제 #1
0
Tools_toolbar::Tools_toolbar(CGAL::Qt_widget *w,
			     QMainWindow *mw) : QToolBar(mw, "NT")
  {
    w->attach(&input_point);
    input_point.deactivate();
    w->attach(&input_line);
    input_line.deactivate();
    w->attach(&input_polygon);
    input_polygon.deactivate();

    //set the widget
    widget = w;

    QIconSet set0(QPixmap( (const char**)arrow_small_xpm ),
                  QPixmap( (const char**)arrow_xpm ));
    QIconSet set1(QPixmap( (const char**)point_small_xpm ),
                  QPixmap( (const char**)point_xpm ));
    QIconSet set2(QPixmap( (const char**)line_small_xpm ),
                  QPixmap( (const char**)line_xpm ));
    QIconSet set3(QPixmap( (const char**)polygon_small_xpm ),
                  QPixmap( (const char**)polygon_xpm ));

  but[0] = new QToolButton(this, "Deactivate Layer");
  but[0]->setIconSet(set0);
  but[0]->setTextLabel("Deactivate Layer");
  but[1] = new QToolButton(this, "pointinput layer");
  but[1]->setIconSet(set1);
  but[1]->setTextLabel("Input Point");
  but[2] = new QToolButton(this, "lineinput layer");
  but[2]->setIconSet(set2);
  but[2]->setTextLabel("Input Line");
  but[3] = new QToolButton(this, "polygoninput layer");
  but[3]->setIconSet(set3);
  but[3]->setTextLabel("Input Simple Polygon");

  nr_of_buttons = 4;
  button_group = new QButtonGroup(0, "My_group");
  for(int i = 0; i<nr_of_buttons; i++) {
    button_group->insert(but[i]);
    but[i]->setToggleButton(true);
  }
  button_group->setExclusive(true);

  connect(but[1], SIGNAL(stateChanged(int)),
        &input_point, SLOT(stateChanged(int)));
  connect(but[2], SIGNAL(stateChanged(int)),
        &input_line, SLOT(stateChanged(int)));
  connect(but[3], SIGNAL(stateChanged(int)),
        &input_polygon, SLOT(stateChanged(int)));
}
예제 #2
0
TEST(IntervalTest, InfixOperator)
{
  IntervalSet<int> set1(Bound<int>::closed(0), Bound<int>::closed(1));
  IntervalSet<int> set2(Bound<int>::closed(2), Bound<int>::open(3));
  IntervalSet<int> set3(Bound<int>::closed(0), Bound<int>::closed(2));

  EXPECT_EQ(set3, set1 + set2);
  EXPECT_EQ(set3, set1 + (Bound<int>::closed(2), Bound<int>::open(3)));
  EXPECT_EQ(set3, set1 + 2);

  EXPECT_EQ(set1, set3 - set2);
  EXPECT_EQ(set2, set3 - (Bound<int>::closed(0), Bound<int>::closed(1)));
  EXPECT_EQ(set1, set3 - 2);
}
예제 #3
0
TEST(TSet, check_size_changes_of_the_combination_of_two_sets_of_non_equal_size)
{
  const int size1 = 5, size2 = 7;
  TSet set1(size1), set2(size2), set3(size1);
  // set1 = {1, 2, 4}
  set1.InsElem(1);
  set1.InsElem(2);
  set1.InsElem(4);
  // set2 = {0, 1, 2}
  set2.InsElem(0);
  set2.InsElem(1);
  set2.InsElem(2);
  set3 = set1 + set2;

  EXPECT_EQ(size2, set3.GetMaxPower());
}
예제 #4
0
파일: DataRefTest.cpp 프로젝트: Cue/skia
static void test_dataset(skiatest::Reporter* reporter) {
    SkDataSet set0(NULL, 0);
    SkDataSet set1("hello", SkTUnref<SkData>(SkData::NewWithCString("world")));

    const SkDataSet::Pair pairs[] = {
        { "one", SkData::NewWithCString("1") },
        { "two", SkData::NewWithCString("2") },
        { "three", SkData::NewWithCString("3") },
    };
    SkDataSet set3(pairs, 3);
    unrefAll(pairs, 3);

    test_dataset(reporter, set0, 0);
    test_dataset(reporter, set1, 1);
    test_dataset(reporter, set3, 3);
}
예제 #5
0
TEST(TSet, can_intersect_two_sets_of_equal_size)
{
  const int size = 5;
  TSet set1(size), set2(size), set3(size), expSet(size);
  // set1 = {1, 2, 4}
  set1.InsElem(1);
  set1.InsElem(2);
  set1.InsElem(4);
  // set2 = {0, 1, 2}
  set2.InsElem(0);
  set2.InsElem(1);
  set2.InsElem(2);
  set3 = set1 * set2;
  // expSet = {1, 2}
  expSet.InsElem(1);
  expSet.InsElem(2);

  EXPECT_EQ(expSet, set3);
}
예제 #6
0
TEST(TSet, product_of_sets)
{
	const int size = 10;
	TSet set0(size), set1(size), set2(size), set3(size), expSet(size);
	set0.InsElem(0);
	set0.InsElem(1);
	set0.InsElem(3);
	set0.InsElem(5);
	set1.InsElem(0);
	set1.InsElem(3);
	set1.InsElem(4);
	set1.InsElem(5);
	set2.InsElem(0);
	set2.InsElem(1);
	set2.InsElem(5);
	set2.InsElem(6);
	set2.InsElem(7);
	set3 = set0 * set1 * set2;
	expSet.InsElem(0);
	expSet.InsElem(5);
	EXPECT_EQ(expSet, set3);
}
예제 #7
0
TEST(TSet, can_combine_two_sets_of_non_equal_size)
{
  const int size1 = 5, size2 = 7;
  TSet set1(size1), set2(size2), set3(size1), expSet(size2);
  // set1 = {1, 2, 4}
  set1.InsElem(1);
  set1.InsElem(2);
  set1.InsElem(4);
  // set2 = {0, 1, 2, 6}
  set2.InsElem(0);
  set2.InsElem(1);
  set2.InsElem(2);
  set2.InsElem(6);
  set3 = set1 + set2;
  // expSet = {0, 1, 2, 4, 6}
  expSet.InsElem(0);
  expSet.InsElem(1);
  expSet.InsElem(2);
  expSet.InsElem(4);
  expSet.InsElem(6);

  EXPECT_EQ(expSet, set3);
}
예제 #8
0
 void    SetDataSize(DWORD size)  { set3(data,1,size);	}
예제 #9
0
// constructor
MyWindow::MyWindow(int w, int h) : 
  red_active(false),
  red_set(*(new Polygon_set)),
  blue_set(*(new Polygon_set)),
  res_set(*(new Polygon_set))										  
{
  widget = new CGAL::Qt_widget(this); //Constructs a widget which is a child of this window


  /* Sets the central widget for this main window to w.
   * The central widget is surrounded by the left, top, right and bottom dock areas.
   * The menu bar is above the top dock area
   */
  setCentralWidget(widget);

  file_name= QString::null;

  //create a timer for checking if somthing changed
  QTimer *timer = new QTimer( this ); // constructs a timer whose parent is this window

  connect( timer, SIGNAL(timeout()),
           this, SLOT(timer_done()) );  // connects the timer to the window
  timer->start( 200, FALSE ); // Starts the timer with a msec milliseconds timeout

  // file menu
  QPopupMenu * file = new QPopupMenu( this );
  menuBar()->insertItem( "&File", file );
  file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N);
  file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W);
  file->insertSeparator();
  file->insertItem("&Open Linear Polygon file", this, SLOT(open_linear_polygon_file()),CTRL+Key_O);
  file->insertItem("&Open DXF file", this, SLOT(open_dxf_file()),CTRL+Key_D);
  file->insertSeparator();
  //file->insertItem("&Save",this ,SLOT(save_file()),CTRL+Key_S);
  //file->insertItem("&Save as",this ,SLOT(save_file_as()));
  file->insertSeparator();
  file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P);
  file->insertSeparator();
  file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
  file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );

  // help menu
  QPopupMenu * help = new QPopupMenu( this );
  menuBar()->insertItem( "&Help", help );
  help->insertItem("How To", this, SLOT(howto()), Key_F1);
  help->insertSeparator();
  help->insertItem("&About", this, SLOT(about()), CTRL+Key_A );
  help->insertItem("About &Qt", this, SLOT(aboutQt()) );

  //the standard toolbar
  stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST");

  radiotoolbar = new QToolBar(this, "polygon type");
  blue_pgn = new QRadioButton ("Blue", radiotoolbar);
  blue_pgn->toggle();
  red_pgn = new QRadioButton("Red", radiotoolbar);
  radio_group = new QVButtonGroup(this,"Radios");
  radio_group->insert(blue_pgn);
  radio_group->insert(red_pgn);
  radio_group->setRadioButtonExclusive(true);


  connect(blue_pgn, SIGNAL(toggled (bool)),
	  this, SLOT(radio_selected()));
  connect(red_pgn, SIGNAL(toggled (bool)),
	  this, SLOT(radio_selected()));


  //layers
  //widget->attach(&testlayer);

  //the new tools toolbar
  newtoolbar = new Tools_toolbar(widget, this);

  // voronoi toolbar
  bops_toolbar = new QToolBar(this, "Boolean operations");

  QIconSet set0(QPixmap( (const char**)intersection_xpm ),
		QPixmap( (const char**)intersection_xpm ));

  intersection_but = new QToolButton(bops_toolbar, "Boolean operations");
  intersection_but->setAutoRaise(TRUE);

  intersection_but->setIconSet(set0);
  intersection_but->setTextLabel("Intersection ");
  connect(intersection_but,SIGNAL(pressed()),
	  this, SLOT(perform_intersection()));

  QIconSet set1(QPixmap( (const char**)union_xpm ),
		QPixmap( (const char**)union_xpm ));

  bops_toolbar->addSeparator();
  union_but = new QToolButton(bops_toolbar, "Boolean operations");
  union_but->setAutoRaise(TRUE);

  union_but->setIconSet(set1);
  union_but->setTextLabel("Union ");
  connect(union_but,SIGNAL(pressed()),
	  this, SLOT(perform_union()));

  QIconSet set2(QPixmap( (const char**)diff_PQ_xpm ),
		QPixmap( (const char**)diff_PQ_xpm ));

  bops_toolbar->addSeparator();
  diff_but2 = new QToolButton(bops_toolbar, "Boolean operations");
  diff_but2->setAutoRaise(TRUE);

  diff_but2->setIconSet(set2);
  diff_but2->setTextLabel("Difference between Blue and Red");
  connect(diff_but2, SIGNAL(pressed()),
	  this, SLOT(perform_diff2()));

  QIconSet set3(QPixmap( (const char**)diff_QP_xpm ),
		QPixmap( (const char**)diff_QP_xpm ));

  bops_toolbar->addSeparator();
  diff_but = new QToolButton(bops_toolbar, "Boolean operations");
  diff_but->setAutoRaise(TRUE);

  diff_but->setIconSet(set3);
  diff_but->setTextLabel("Difference between Red and Blue");
  connect(diff_but, SIGNAL(pressed()),
	  this, SLOT(perform_diff()));

  QIconSet set4(QPixmap( (const char**)symm_diff_xpm ),
		QPixmap( (const char**)symm_diff_xpm ));
  bops_toolbar->addSeparator();

  symm_diff_but = new QToolButton(bops_toolbar, "Boolean operations");
  symm_diff_but->setAutoRaise(TRUE);

  symm_diff_but->setIconSet(set4);
  symm_diff_but->setTextLabel("Symmetric Difference ");
  connect(symm_diff_but, SIGNAL(pressed()),
	  this, SLOT(perform_symm_diff()));

  QIconSet set12(QPixmap( (const char**)mink_sum_xpm ),
		 QPixmap( (const char**)mink_sum_xpm ));
  bops_toolbar->addSeparator();
  mink_sum_but = new QToolButton(bops_toolbar, "Boolean operations");
  mink_sum_but->setAutoRaise(TRUE);
  mink_sum_but->setIconSet(set12);
  mink_sum_but->setTextLabel("Minkowski Sum ");
  connect(mink_sum_but, SIGNAL(pressed()),
	  this, SLOT(perform_mink_sum()));

  QIconSet set5(QPixmap( (const char**)comp_P_xpm ),
		QPixmap( (const char**)comp_P_xpm ));
  bops_toolbar->addSeparator();

  blue_complement_but = new QToolButton(bops_toolbar, "Boolean operations");
  blue_complement_but->setAutoRaise(TRUE);

  blue_complement_but->setIconSet(set5);
  blue_complement_but->setTextLabel("Blue Complement ");
  connect(blue_complement_but, SIGNAL(pressed()),
	  this, SLOT(perform_blue_complement()));

  QIconSet set6(QPixmap( (const char**)comp_Q_xpm ),
		QPixmap( (const char**)comp_Q_xpm ));
  bops_toolbar->addSeparator();

  red_complement_but = new QToolButton(bops_toolbar, "Boolean operations");
  red_complement_but->setAutoRaise(TRUE);

  red_complement_but->setIconSet(set6);
  red_complement_but->setTextLabel("Red Complement ");
  connect(red_complement_but, SIGNAL(pressed()),
	  this, SLOT(perform_red_complement()));


  QIconSet set7(QPixmap( (const char**)make_P_xpm ),
		QPixmap( (const char**)make_P_xpm ));
  bops_toolbar->addSeparator();
  make_res_blue_but = new QToolButton(bops_toolbar, "Boolean operations");
  make_res_blue_but->setAutoRaise(TRUE);


  make_res_blue_but->setIconSet(set7);
  make_res_blue_but->setTextLabel("Make Result Blue");
  connect(make_res_blue_but,SIGNAL(pressed()),
	  this, SLOT(make_res_blue()));

  QIconSet set8(QPixmap( (const char**)make_Q_xpm ),
		QPixmap( (const char**)make_Q_xpm ));
  bops_toolbar->addSeparator();
  make_res_red_but = new QToolButton(bops_toolbar, "Boolean operations");
  make_res_red_but->setAutoRaise(TRUE);


  make_res_red_but->setIconSet(set8);
  make_res_red_but->setTextLabel("Make Result Red");
  connect(make_res_red_but,SIGNAL(pressed()),
	  this, SLOT(make_res_red()));

  QIconSet set9(QPixmap( (const char**)refresh_xpm ),
		QPixmap( (const char**)refresh_xpm ));
  bops_toolbar->addSeparator();

  refresh_but = new QToolButton(bops_toolbar, "Boolean operations");
  refresh_but->setAutoRaise(TRUE);

  refresh_but->setIconSet(set9);
  refresh_but->setTextLabel("Refresh ");
  connect(refresh_but,SIGNAL(pressed()),
	  this, SLOT(refresh()));

  QIconSet set10(QPixmap( (const char**)del_P_xpm ),
		 QPixmap( (const char**)del_P_xpm ));
  bops_toolbar->addSeparator();

  delete_blue_but = new QToolButton(bops_toolbar, "Boolean operations");
  delete_blue_but->setAutoRaise(TRUE);

  delete_blue_but->setIconSet(set10);
  delete_blue_but->setTextLabel("Delete Blue Polygons");
  connect(delete_blue_but,SIGNAL(pressed()),
	  this, SLOT(delete_blue_polygons()));


  QIconSet set11(QPixmap( (const char**)del_Q_xpm ),
		 QPixmap( (const char**)del_Q_xpm ));
  bops_toolbar->addSeparator();

  delete_red_but = new QToolButton(bops_toolbar, "Boolean operations");
  delete_red_but->setAutoRaise(TRUE);

  delete_red_but->setIconSet(set11);
  delete_red_but->setTextLabel("Delete Red Polygons");
  connect(delete_red_but,SIGNAL(pressed()),
	  this, SLOT(delete_red_polygons()));




  *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor (CGAL::BLACK);

  resize(w,h);
  widget->set_window(-1, 1, -1, 1);
  widget->setMouseTracking(TRUE);

  //connect the widget to the main function that receives the objects
  connect(widget, SIGNAL(new_cgal_object(CGAL::Object)),
	  this, SLOT(get_new_object(CGAL::Object)));

  //application flag stuff
  old_state = 0;
  current_state = 1;
  red_active = false;
  red_set.clear();
  blue_set.clear();
  res_set.clear();
}
예제 #10
0
void dlgSelectConnection::OnChangeServer(wxCommandEvent &ev)
{
	int item;
	wxString olddatabase, oldusername;

	if (!GetServer())
		return;

	// Keep old value for these comboboxes so that we can restore them if needed
	olddatabase = cbDatabase->GetValue();
	oldusername = cbUsername->GetValue();

	// Clear the comboboxes
	cbDatabase->Clear();
	cbUsername->Clear();
	cbRolename->Clear();

	int sel = cbServer->GetCurrentSelection();
	if (sel >= 0)
	{
		remoteServer = (pgServer *)cbServer->wxItemContainer::GetClientData(sel);

		if (!remoteServer->GetConnected())
		{
			remoteServer->Connect(mainForm, remoteServer->GetStorePwd());
			if (!remoteServer->GetConnected())
			{
				wxLogError(wxT("%s"), remoteServer->GetLastError().c_str());
				return;
			}
		}
		if (remoteServer->GetConnected())
		{
			pgSetIterator set1(remoteServer->GetConnection(),
			                   wxT("SELECT DISTINCT datname\n")
			                   wxT("  FROM pg_database db\n")
			                   wxT(" WHERE datallowconn ORDER BY datname"));

			item = 0;
			while(set1.RowsLeft())
			{
				cbDatabase->Append(set1.GetVal(wxT("datname")));
				if (set1.GetVal(wxT("datname")) == olddatabase)
					item = cbDatabase->GetCount() - 1;
			}

			if (cbDatabase->GetCount())
				cbDatabase->SetSelection(item);

			pgSetIterator set2(remoteServer->GetConnection(),
			                   wxT("SELECT DISTINCT usename\n")
			                   wxT("FROM pg_user db\n")
			                   wxT("ORDER BY usename"));

			item = 0;
			while(set2.RowsLeft())
			{
				cbUsername->Append(set2.GetVal(wxT("usename")));
				if (set2.GetVal(wxT("usename")) == oldusername)
					item = cbDatabase->GetCount() - 1;
			}

			if (cbUsername->GetCount())
				cbUsername->SetSelection(item);

			if (remoteServer->GetConnection()->BackendMinimumVersion(8, 1))
			{
				pgSetIterator set3(remoteServer->GetConnection(),
				                   wxT("SELECT DISTINCT rolname\n")
				                   wxT("FROM pg_roles db\n")
				                   wxT("ORDER BY rolname"));

				cbRolename->Append(wxEmptyString);

				while(set3.RowsLeft())
					cbRolename->Append(set3.GetVal(wxT("rolname")));

				cbRolename->Enable(true);
			}
			else
				cbRolename->Disable();

			cbRolename->SetValue(wxEmptyString);
		}

	}
	OnChangeDatabase(ev);
}
Layers_toolbar::Layers_toolbar(CGAL::Qt_widget*        w
                              ,QMainWindow*            mw
                              ,demo::Regions  const&   in
                              ,demo::SSkelPtr const&   sskel
                              ,demo::Regions  const&   out
                              ) : QToolBar(mw, "LT"),
     nr_of_buttons(0)
  {
    showI     = new Qt_layer_show_regions <demo::Regions> (this,"Input",in,CGAL::RED);
    showSSkel = new Qt_layer_show_skeleton<demo::SSkel>   (this,"Skeleton",sskel);
    showO     = new Qt_layer_show_regions <demo::Regions> (this,"Offset",out,CGAL::BLACK);
    progress  = new Qt_layer_show_progress                (this,"Progress");

    //set the widget
    widget = w;
    window = mw;

    widget->attach(showI);
    widget->attach(progress);
    widget->attach(showSSkel);
    widget->attach(showO);

    QIconSet set0(QPixmap( (const char**)show_polygon_small_xpm ),
                  QPixmap( (const char**)show_polygon_xpm ));
    QIconSet set1(QPixmap( (const char**)voronoi_small_xpm ),
                  QPixmap( (const char**)voronoi_xpm ));
    QIconSet set2(QPixmap( (const char**)polygon_small_xpm ),
                  QPixmap( (const char**)polygon_xpm ));
    QIconSet set3(QPixmap( (const char**)polygon_small_xpm ),
                  QPixmap( (const char**)polygon_xpm ));

    but[0] = new QToolButton(this, "polygon");
    but[0]->setIconSet(set0);
    but[0]->setTextLabel("Show Simple Polygon");

    but[1] = new QToolButton(this, "straight_skeleton");
    but[1]->setIconSet(set1);
    but[1]->setTextLabel("Show Straight Skeleton");

    but[2] = new QToolButton(this, "offset");
    but[2]->setIconSet(set2);
    but[2]->setTextLabel("Show Polygon Offset");

    but[3] = new QToolButton(this, "progress");
    but[3]->setIconSet(set3);
    but[3]->setTextLabel("Show Progress");

    nr_of_buttons = 4;
    button_group = new QButtonGroup(0, "nonexclusive");

    for(int i =0; i<nr_of_buttons; i++){
      but[i]->setToggleButton(true);
      but[i]->toggle();
      button_group->insert(but[i]);
    }
    //but[1]->toggle();
    connect(but[0], SIGNAL(stateChanged(int)),
        showI, SLOT(stateChanged(int)));
    connect(but[1], SIGNAL(stateChanged(int)),
        showSSkel, SLOT(stateChanged(int)));
    connect(but[2], SIGNAL(stateChanged(int)),
        showO, SLOT(stateChanged(int)));
    connect(but[3], SIGNAL(stateChanged(int)),
        progress, SLOT(stateChanged(int)));
  }
예제 #12
0
파일: main.cpp 프로젝트: drthomas21/CS332C
int main() {
	srand(static_cast<unsigned int>(time(NULL)));
	std::vector<int> set1(10,0);
	set1[9] = 31;
	set1[8] = 30;
	set1[7] = 24;
	set1[6] = 15;
	set1[5] = 13;
	set1[4] = 10;
	set1[3] = 9;
	set1[2] = 5;
	set1[1] = 4;
	set1[0] = 2;
	MySet obj1(set1);

	std::cout << "Set 1: " << obj1 << std::endl << std::endl;

	//Insert
	for (int i = 0; i < 20; i++) {
		int randNum = rand() % 1000;
		std::cout << "Lets insert " << randNum << " into the set";
		obj1.insert(randNum);
		std::cout << obj1 << std::endl << std::endl;
	}

	//Remove
	for (int i = 0; i < 20; i++) {
		int randNum = rand() % 20;
		std::cout << "Lets remove " << randNum << " into the set";
		obj1.remove(randNum);
		std::cout << obj1 << std::endl << std::endl;
	}

	std::cout << std::endl << std::endl;
	

	//New Set
	std::vector<int> set2(30,0);
	for (int i = 0; i < set2.size(); i++) {
		set2[i] = rand() % 1000;
	}
	MySet obj2(set2);
	std::cout << "Set 2: " << obj2 << std::endl;

	std::vector<int> set3(30, 0);
	for (int i = 0; i < set3.size(); i++) {
		set3[i] = rand() % 1000;
	}
	MySet obj3(set3);
	std::cout << "Set 3: " << obj3 << std::endl;

	//Add
	std::cout << "Set 3 + Set 2: ";
	std::cout << (obj3 + obj2) << std::endl << std::endl;

	//Sub
	std::cout << "Set 3 - Set 2: ";
	std::cout << (obj3 - obj2) << std::endl << std::endl;

	//Intersect
	std::cout << "Set 3 & Set 2: ";
	std::cout << (obj3 & obj2) << std::endl << std::endl;

	//Equals
	std::cout << "Set 3 == Set 2: ";
	std::cout << (obj3 == obj2 ? "Yes" : "No") << std::endl << std::endl << std::endl;

	//New Set
	std::vector<int> set4(30, 0);
	for (int i = 0; i < set4.size(); i++) {
		set4[i] = rand() % 1000;
	}
	MySet obj4(set4);
	std::cout << "Set 4: " << obj4 << std::endl;

	MySet obj5(set4);
	std::cout << "Set 5: " << obj5 << std::endl;

	//Equals
	std::cout << "Set 4 == Set 5: ";
	std::cout << (obj4 == obj5 ? "Yes" : "No") << std::endl;

	return 0;
}
Tools_toolbar::Tools_toolbar(CGAL::Qt_widget *w,
			     QMainWindow *mw, std::vector<Point_2> *l1) :
  QToolBar(mw, "NT")
  {
    w->attach(&edit_layer);
    w->attach(&point_layer);
    w->attach(&iso_r_layer);
    w->attach(&circle_layer);
    edit_layer.deactivate();
    point_layer.deactivate();
    iso_r_layer.deactivate();
    circle_layer.deactivate();
    edit_layer.pass_the_structure(l1);

    //set the widget
    widget = w;

    QIconSet set0(QPixmap( (const char**)arrow_small_xpm ),
                  QPixmap( (const char**)arrow_xpm ));
    QIconSet set1(QPixmap( (const char**)point_small_xpm ),
                  QPixmap( (const char**)point_xpm ));
    QIconSet set2(QPixmap( (const char**)iso_rectangle_small_xpm ),
                  QPixmap( (const char**)iso_rectangle_xpm ));
    QIconSet set3(QPixmap( (const char**)circle_small_xpm ),
                  QPixmap( (const char**)circle_xpm ));
    QIconSet set4(QPixmap( (const char**)movepoint_small_xpm ),
                  QPixmap( (const char**)movepoint_xpm ));


  but[0] = new QToolButton(this, "deactivate layer");
  but[0]->setIconSet(set0);
  but[0]->setTextLabel("Deactivate Layer");
  but[1] = new QToolButton(this, "pointtool");
  but[1]->setIconSet(set1);
  but[1]->setTextLabel("Input Point");
  but[2] = new QToolButton(this, "iso_rectangle");
  but[2]->setIconSet(set2);
  but[2]->setTextLabel("Input Iso_rectangle");
  but[3] = new QToolButton(this, "iso_rectangle");
  but[3]->setIconSet(set3);
  but[3]->setTextLabel("Input Circle");
  but[4] = new QToolButton(this, "move/delete tool");
  but[4]->setIconSet(set4);
  but[4]->setTextLabel("Move/Delete Point");

  nr_of_buttons = 5;
  button_group = new QButtonGroup(0, "My_group");
  for(int i = 0; i<nr_of_buttons; i++) {
    button_group->insert(but[i]);
    but[i]->setToggleButton(true);
  }
  button_group->setExclusive(true);

  connect(but[1], SIGNAL(stateChanged(int)),
        &point_layer, SLOT(stateChanged(int)));
  connect(but[2], SIGNAL(stateChanged(int)),
        &iso_r_layer, SLOT(stateChanged(int)));
  connect(but[3], SIGNAL(stateChanged(int)),
        &circle_layer, SLOT(stateChanged(int)));
  connect(but[4], SIGNAL(stateChanged(int)),
        &edit_layer, SLOT(stateChanged(int)));
  but[1]->toggle();
}
예제 #14
0
static void TestBitSet(skiatest::Reporter* reporter) {
    SkBitSet set0(65536);
    REPORTER_ASSERT(reporter, set0.isBitSet(0) == false);
    REPORTER_ASSERT(reporter, set0.isBitSet(32767) == false);
    REPORTER_ASSERT(reporter, set0.isBitSet(65535) == false);

    SkBitSet set1(65536);
    REPORTER_ASSERT(reporter, set0 == set1);

    set0.setBit(22, true);
    REPORTER_ASSERT(reporter, set0.isBitSet(22) == true);
    set0.setBit(24, true);
    REPORTER_ASSERT(reporter, set0.isBitSet(24) == true);
    set0.setBit(35, true);  // on a different DWORD
    REPORTER_ASSERT(reporter, set0.isBitSet(35) == true);
    set0.setBit(22, false);
    REPORTER_ASSERT(reporter, set0.isBitSet(22) == false);
    REPORTER_ASSERT(reporter, set0.isBitSet(24) == true);
    REPORTER_ASSERT(reporter, set0.isBitSet(35) == true);

    SkTDArray<unsigned int> data;
    set0.exportTo(&data);
    REPORTER_ASSERT(reporter, data.count() == 2);
    REPORTER_ASSERT(reporter, data[0] == 24);
    REPORTER_ASSERT(reporter, data[1] == 35);

    set1.setBit(12345, true);
    set1.orBits(set0);
    REPORTER_ASSERT(reporter, set0.isBitSet(12345) == false);
    REPORTER_ASSERT(reporter, set1.isBitSet(12345) == true);
    REPORTER_ASSERT(reporter, set1.isBitSet(22) == false);
    REPORTER_ASSERT(reporter, set1.isBitSet(24) == true);
    REPORTER_ASSERT(reporter, set0.isBitSet(35) == true);
    REPORTER_ASSERT(reporter, set1 != set0);

    set1.clearAll();
    REPORTER_ASSERT(reporter, set0.isBitSet(12345) == false);
    REPORTER_ASSERT(reporter, set1.isBitSet(12345) == false);
    REPORTER_ASSERT(reporter, set1.isBitSet(22) == false);
    REPORTER_ASSERT(reporter, set1.isBitSet(24) == false);
    REPORTER_ASSERT(reporter, set1.isBitSet(35) == false);

    set1.orBits(set0);
    REPORTER_ASSERT(reporter, set1 == set0);

    SkBitSet set2(1);
    SkBitSet set3(1);
    SkBitSet set4(4);
    SkBitSet set5(33);

    REPORTER_ASSERT(reporter, set2 == set3);
    REPORTER_ASSERT(reporter, set2 != set4);
    REPORTER_ASSERT(reporter, set2 != set5);

    set2.setBit(0, true);
    REPORTER_ASSERT(reporter, set2 != set5);
    set5.setBit(0, true);
    REPORTER_ASSERT(reporter, set2 != set5);
    REPORTER_ASSERT(reporter, set2 != set3);
    set3.setBit(0, true);
    REPORTER_ASSERT(reporter, set2 == set3);
    set3.clearAll();
    set3 = set2;
    set2 = set2;
    REPORTER_ASSERT(reporter, set2 == set3);
}
예제 #15
0
int main()
{
  std::mt19937 gen;
  gen.seed(std::chrono::system_clock::now().time_since_epoch().count());

  //Settings
  MotifGenSettings set1(1.5, &gen, 3);

  //Create some global abstract motifs
  std::vector<AbstractMotif> am;
  am.push_back(AbstractMotif(set1));
  am.push_back(AbstractMotif(set1));
  am.push_back(AbstractMotif(set1));
  set1.length = 1;
  am.push_back(AbstractMotif(set1));
  am.push_back(AbstractMotif(set1));
  am.push_back(AbstractMotif(set1));

  //Abstract themes
  ThemeGenSettings set2(3, am, .25, &gen, 3);
  AbstractTheme at1(set2);
  set2.concreteness = .5;
  AbstractTheme at2(set2);
  set2.concreteness = .75;
  AbstractTheme at3(set2);
  set2.concreteness = 1;
  AbstractTheme at4(set2);
  AbstractTheme at5(set2);

  //Concrete themes
  ThemeConcreteSettings set3("C4", 0, 80, midi::Instrument::ACOUSTIC_GRAND_PIANO,
                             1500, &gen, 3);

  midi::NoteTrack nt;
  std::uint32_t ticks = 0;

  ConcreteTheme ct(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  ct.generate(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  ct.generate(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  ct.generate(at4, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  ct.generate(at4, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  ct.generate(at4, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  ct.generate(at4, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //1 1 2 2 3 3 1 1 4 4 5 5 1 1
  //1
  /*
  ConcreteTheme ct(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //1
  ct.generate(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //2
  ct.generate(at2, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //2
  ct.generate(at2, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //3
  ct.generate(at3, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //3
  ct.generate(at3, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //1
  ct.generate(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //1
  ct.generate(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //4
  ct.generate(at4, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //4
  ct.generate(at4, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //5
  ct.generate(at5, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //5
  ct.generate(at5, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //1
  ct.generate(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;

  //1
  ct.generate(at1, set3);
  ct.addToTrack(nt, ticks);
  ticks += ct.ticks() + 5000;*/

  //Save
  midi::MIDI_Type0 mid(nt, midi::TimeDivision(1548));
  mid.write("testtheme.mid");
}
예제 #16
0
 void    SetTimestamp(DWORD ts)   { set3(data,4,ts);	}
예제 #17
0
 void    SetStreamId(DWORD id)	 { set3(data,8,id);	}
예제 #18
0
void
SetTest::run() {
    CSetT<TestKey, TestSetFuncs> defSet;
	TestKey tk1; tk1.setValue("obj1");
    TestKey tk2; tk2.setValue("obj2");
    TestKey tk3; tk3.setValue("obj3");

    defSet.addObject(tk1);
    defSet.addObject(tk2);
    defSet.addObject(tk3);

    if (3 != defSet.count()) testFail(er0);

    CSetT<TestKey, TestSetFuncs>::Iterator iter1(&defSet);

    while (iter1.next()) {
        if (TestSetFuncs<TestKey>::isEqualKeys(&iter1.object(), &tk1, nil)) continue;
        if (TestSetFuncs<TestKey>::isEqualKeys(&iter1.object(), &tk2, nil)) continue;
        if (TestSetFuncs<TestKey>::isEqualKeys(&iter1.object(), &tk3, nil)) continue;
        testFail(er1);
    }

    defSet.removeObject(tk3);
    if (2 != defSet.count()) testFail(er2);

    defSet.removeAllObjects();
    if (0 != defSet.count()) testFail(er3);

	TestKey k5; k5.setValue("k5");
    TestKey k6; k6.setValue("k6");
    TestKey k7; k7.setValue("k7");
	TestKey k8; k8.setValue("k8");
	TestKey k9; k9.setValue("k9");
	TestKey s_1; s_1.setValue("s1");
	TestKey s_2; s_2.setValue("s2");
	TestKey s_3; s_3.setValue("s3");

    TestKey arrms[] = { k5, k6, k7, k8 };
    CArrayT<TestKey> arr(arrms, 4);
    
    TestKey tkss[] = { s_1, s_2, s_3 };
    CSetT<TestKey, TestSetFuncs> set(tkss, 3);

    set.addObjectsFromArray(&arr);

    if (7 != set.count()) testFail(er4);

    CSetT<TestKey, TestSetFuncs> set2(&arr);
    if (4 != set2.count()) testFail(er5);
    
    set.removeObject(s_1);
    set.removeObject(s_2);
    set.removeObject(s_3);

    if (!set2.isEqualToSet(&set)) testFail(er6);
    if (!set2.containsObject(k5)) testFail(er7);
    if (set2.containsObject(s_1)) testFail(er7);

    set.allObjects(&arr);

    if (arr.count() != set.count()) testFail(er8);
    for (dInteger i = 0, cnt = arr.count(); i < cnt; ++i)
        if (!set.containsObject(arr.objectAtIndex(i))) testFail(er8);

    try {
        set.member(k6);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        testFail(er9);
        SAFE_DELETE(e);
    }
    try {
        set.member(k9);
        testFail(er9);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        SAFE_DELETE(e);
    }


    CSetT<TestKey, TestSetFuncs> set3(set2);

    if (!set3.isEqualToSet(&set2)) testFail(er5);

    TestKey* cSet = new TestKey[3];
    cSet[0].setValue("b1");
    cSet[1].setValue("b2");
    cSet[2].setValue("b3");

    CSetT<TestKey, TestSetFuncs> setCSet(cSet, 3);
    SAFE_DELETE_ARRAY(cSet);

    if (3 != setCSet.count()) testFail(er5);
	
	TestKey b1; b1.setValue("b1");
    TestKey b2; b2.setValue("b2");
    TestKey b3; b3.setValue("b3");
	TestKey b4; b4.setValue("b4");

    if (!setCSet.containsObject(b1)) testFail(er5);
    if (!setCSet.containsObject(b2)) testFail(er5);
    if (!setCSet.containsObject(b3)) testFail(er5);
    if (setCSet.containsObject(b4)) testFail(er5);

    try {
        TestKey anyKey = setCSet.anyObject();
        if (!setCSet.containsObject(anyKey)) testFail(er10);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        testFail(er10);
        SAFE_DELETE(e);
    }

    setCSet.removeAllObjects();

    try {
        setCSet.anyObject();
        testFail(er10);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        SAFE_DELETE(e);
    }


	TestKey newobj; newobj.setValue("newObj");
    CSetT<TestKey, TestSetFuncs>* newly = set3.newSetByAddingObject(newobj);
    if (!newly->containsObject(newobj)) testFail(er11);
    SAFE_DELETE(newly);

	TestKey k1; k1.setValue("kk1");
	TestKey k2; k2.setValue("kk2");
	TestKey k3; k3.setValue("kk3");
	TestKey k4; k4.setValue("kk4");
	TestKey l1; l1.setValue("l1");
	TestKey l2; l2.setValue("l2");
	TestKey l3; l3.setValue("l3");
	
    TestKey keysms[] = { k1, k2, k3 };
	CArrayT<TestKey> keys(keysms, 3);
    CSetT<TestKey, TestSetFuncs>* newly2 = set3.newSetByAddingObjectsFromArray(&keys);
    if (!newly2->containsObject(k1)) testFail(er12);
    if (!newly2->containsObject(k2)) testFail(er12);
    if (newly2->containsObject(k4)) testFail(er12);
    if (!newly2->containsObject(k3)) testFail(er12);
    if (!newly2->containsObject(set3.anyObject())) testFail(er12);
    SAFE_DELETE(newly2);

    TestKey oness[] = { l1, l2 };
    CSetT<TestKey, TestSetFuncs> oneSet(oness, 2);
    CSetT<TestKey, TestSetFuncs> secondSet(&l3, 1);
    secondSet.unionSet(&oneSet);

    if (3 != secondSet.count()) testFail(er14);
    if (!secondSet.containsObject(l2)) testFail(er14);
    if (!secondSet.containsObject(l3)) testFail(er14);
    if (!secondSet.containsObject(l1)) testFail(er14);


    CSetT<TestKey, TestSetFuncs>* thirdSet = secondSet.newSetByAddingObjectsFromSet(&set3);
    if (!thirdSet->containsObject(l2)) testFail(er13);
    if (!thirdSet->containsObject(set3.anyObject())) testFail(er13);
    if (!thirdSet->containsObject(l3)) testFail(er13);
    if (!thirdSet->containsObject(l1)) testFail(er13);
    SAFE_DELETE(thirdSet);


	TestKey one; one.setValue("one");
	TestKey two; two.setValue("two");
	TestKey three; three.setValue("three");
	TestKey four; four.setValue("four");
	TestKey fifth; fifth.setValue("fifth");
	TestKey six; six.setValue("six");
	
    TestKey rss[] = { one, two, three, four };
    CSetT<TestKey, TestSetFuncs> rSet(rss, 4);
    TestKey r2ss[] = { one, three, four };
    CSetT<TestKey, TestSetFuncs> rSet2(r2ss, 3);
    rSet.minusSet(&rSet2);

    if (1 != rSet.count()) testFail(er15);
    TestKey tTwo; tTwo.setValue("two");
    if (!TestSetFuncs<TestKey>::isEqualKeys(&rSet.anyObject(), &tTwo, nil)) testFail(er15);


    TestKey iss[] = { one, fifth, six, four };
    CSetT<TestKey, TestSetFuncs> iSet(rss, 4);
    CSetT<TestKey, TestSetFuncs> iSet2(iss, 4);
    iSet.intersectSet(&iSet2);

    CSetT<TestKey, TestSetFuncs>::Iterator iSetIter(&iSet);
    TestKey tOne; tOne.setValue("one");
    TestKey tFour; tFour.setValue("four");

    while (iSetIter.next()) {
        if (TestSetFuncs<TestKey>::isEqualKeys(&iSetIter.object(), &tOne, nil)) continue;
        if (TestSetFuncs<TestKey>::isEqualKeys(&iSetIter.object(), &tFour, nil)) continue;
        testFail(er16);
    }

	TestKey boo1; boo1.setValue("boo1");
	TestKey boo2; boo2.setValue("boo2");
	TestKey boo3; boo3.setValue("boo3");
	TestKey boo4; boo4.setValue("boo4");
	TestKey capacity; capacity.setValue("capacity");
	TestKey other; other.setValue("other");
	TestKey bla; bla.setValue("bla-bla");
	TestKey yahoo; yahoo.setValue("yahoo");
	
    TestKey pss[] = { boo1, boo2, boo3 };
    CSetT<TestKey, TestSetFuncs> pSet(pss, 3);
    iSet.setSet(&pSet);

    if (iSet.containsObject(one)) testFail(er17);
    if (iSet.containsObject(four)) testFail(er17);
    if (!iSet.containsObject(boo1)) testFail(er17);
    if (!iSet.containsObject(boo3)) testFail(er17);

    CSetT<TestKey, TestSetFuncs> capacitySet(10);
    capacitySet.addObject(capacity);
    if (1 != capacitySet.count()) testFail(er5);
    if (!capacitySet.containsObject(capacity)) testFail(er5);


    iSet.addObject(other);
    TestKey subss[] = { boo1, boo3 };
    CSetT<TestKey, TestSetFuncs> subSet(subss, 2);

    if (!subSet.isSubsetOfSet(&iSet)) testFail(er18);
    if (subSet.isSubsetOfSet(&capacitySet)) testFail(er18);


    TestKey i1ss[] = { yahoo, bla, boo3 };
    CSetT<TestKey, TestSetFuncs> interSet1(i1ss, 3);
    TestKey i2ss[] = { yahoo, bla, boo4 };
    CSetT<TestKey, TestSetFuncs> interSet2(i2ss, 3);

    if (!subSet.intersectsSet(&interSet1)) testFail(er19);
    if (subSet.intersectsSet(&interSet2)) testFail(er19);
}