void NewGeneVariableSummaryScrollArea::HandleChanges(DataChangeMessage const & change_message)
{

	UIOutputProject * project = projectManagerUI().getActiveUIOutputProject();

	if (project == nullptr)
	{
		return;
	}

	UIMessager messager(project);

	std::for_each(change_message.changes.cbegin(), change_message.changes.cend(), [this](DataChange const & change)
	{
		switch (change.change_type)
		{
			case DATA_CHANGE_TYPE::DATA_CHANGE_TYPE__INPUT_MODEL__VG_CHANGE:
				{
					switch (change.change_intention)
					{

						case DATA_CHANGE_INTENTION__ADD:
							{

								RefreshAllWidgets(); // this triggers a resort by loading everything in the pane again

							}
							break;

						case DATA_CHANGE_INTENTION__REMOVE:
							{

								if (change.parent_identifier.code && change.parent_identifier.uuid)
								{

									WidgetInstanceIdentifier vg_to_remove(change.parent_identifier);

									int current_number = layout()->count();
									bool found = false;
									QWidget * widgetToRemove = nullptr;
									QLayoutItem * layoutItemToRemove = nullptr;
									int i = 0;

									for (i = 0; i < current_number; ++i)
									{
										QLayoutItem * testLayoutItem = layout()->itemAt(i);
										QWidget * testWidget(testLayoutItem->widget());

										try
										{
											NewGeneVariableSummaryGroup * testVG = dynamic_cast<NewGeneVariableSummaryGroup *>(testWidget);

											if (testVG && testVG->data_instance.IsEqual(WidgetInstanceIdentifier::EQUALITY_CHECK_TYPE__UUID_PLUS_STRING_CODE, vg_to_remove))
											{
												widgetToRemove = testVG;
												layoutItemToRemove = testLayoutItem;
												found = true;

												if (testVG->data_instance.IsEqual(WidgetInstanceIdentifier::EQUALITY_CHECK_TYPE__UUID_PLUS_STRING_CODE, cached_active_vg))
												{
													// No need to call DoTabChange as the entire block will be removed, but save the new empty value into the cache variable
													cached_active_vg = WidgetInstanceIdentifier{};
												}

												break;
											}
										}
										catch (std::bad_cast &)
										{
											// guess not
										}

									}

									if (found && widgetToRemove != nullptr)
									{
										layout()->takeAt(i);
										delete widgetToRemove;
										delete layoutItemToRemove;
										widgetToRemove = nullptr;
										layoutItemToRemove = nullptr;
									}

								}

							}
							break;

						case DATA_CHANGE_INTENTION__UPDATE:
							{
								// Should never receive this.
							}
							break;

						case DATA_CHANGE_INTENTION__RESET_ALL:
							{
								// Ditto above.
								RefreshAllWidgets();
							}
							break;

						default:
							{
							}
							break;

					}
				}
				break;

			default:
				{
				}
				break;
		}
	});

}
Пример #2
0
StartWindow::StartWindow(void)
	:
	BWindow(BRect(0, 0, -1, -1), "Paladin", B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	RegisterWindow();

	AddShortcut('O', B_COMMAND_KEY, new BMessage(M_SHOW_OPEN_PROJECT));
	AddShortcut('N', B_COMMAND_KEY, new BMessage(M_NEW_PROJECT));
	AddShortcut('I', B_COMMAND_KEY, new BMessage(M_SHOW_IMPORT));

	AddCommonFilter(new EscapeCancelFilter());

	// new button and label

	fNewButton = make_button("new", "NewProjectButtonUp.png",
		"NewProjectButtonDown.png", M_NEW_PROJECT);

	ClickableStringView* newLabel = make_label(fNewButton, TR("Create a new project"));
	newLabel->SetMessage(new BMessage(M_NEW_PROJECT));

	// open button and label

	fOpenButton = make_button("open", "OpenProjectButtonUp.png",
		"OpenProjectButtonDown.png", M_SHOW_OPEN_PROJECT);

	ClickableStringView* openLabel = make_label(fOpenButton, "Open a project");
	openLabel->SetMessage(new BMessage(M_SHOW_OPEN_PROJECT));

	// open recent button and label

	fOpenRecentButton = make_button("openrecent", "OpenRecentButtonUp.png",
		"OpenRecentButtonDown.png", M_OPEN_SELECTION);
	SetToolTip(fOpenRecentButton,
		TR("Open a project in the list on the right. You "
		   "can also press Command + a number key."));

	ClickableStringView* openRecentLabel = make_label(fOpenRecentButton,
		TR("Open the selected project"));
	openRecentLabel->SetMessage(new BMessage(M_OPEN_SELECTION));

	// quick import button and label

	fQuickImportButton = make_button("quickimport", "QuickImportButtonUp.png",
		"QuickImportButtonDown.png", M_SHOW_IMPORT);
	SetToolTip(fQuickImportButton,
		TR("Quickly make a project by importing all source files and resource files.\n"
		   "You can also import a BeIDE project."));

	ClickableStringView* quickImportLabel = make_label(fQuickImportButton,
		"Import an existing project");
	quickImportLabel->SetMessage(new BMessage(M_SHOW_IMPORT));
	SetToolTip(quickImportLabel,
		TR("Quickly make a project by importing all source files "
		   "and resource files.\n You can also import a BeIDE project."));

	// online import button and label

	fOnlineImportButton = make_button("onlineimport", "OnlineImportButtonUp.png",
		"OnlineImportButtonDown.png", M_ONLINE_IMPORT);
	SetToolTip(fQuickImportButton,
		TR("Import a project from an online repository"));

	ClickableStringView* onlineImportLabel = make_label(fOnlineImportButton,
		"Import a project from online");
	onlineImportLabel->SetMessage(new BMessage(M_ONLINE_IMPORT));
	SetToolTip(onlineImportLabel, TR("Import a project from an online repository"));

	// recent projects list view and scroller

	fRecentProjectsListView = new RecentProjectsList();
	// set the minimum width to 16em
	float minWidth = fRecentProjectsListView->StringWidth("M") * 16;
	fRecentProjectsListView->SetExplicitMinSize(BSize(minWidth, B_SIZE_UNSET));
	fRecentProjectsListView->SetInvocationMessage(new BMessage(M_OPEN_SELECTION));
	SetToolTip(fRecentProjectsListView,
		"Open a recent project. You can also press Command + a number key.");

	BLayoutBuilder::Group<>(this, B_HORIZONTAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fNewButton, 0, 0)
			.Add(newLabel, 1, 0)

			.Add(fOpenButton, 0, 1)
			.Add(openLabel, 1, 1)

			.Add(fOpenRecentButton, 0, 2)
			.Add(openRecentLabel, 1, 2)

			.Add(fQuickImportButton, 0, 3)
			.Add(quickImportLabel, 1, 3)

			.Add(fOnlineImportButton, 0, 4)
			.Add(onlineImportLabel, 1, 4)
			.End()
		.AddStrut(20)
		.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
			.Add(new BStringView("recentProjectsLabel", TR("Recent projects:")))
			.Add(new BScrollView("recentProjectsScroller", fRecentProjectsListView, 0,
				false, true))
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();

#ifdef DISABLE_ONLINE_IMPORT
	fOnlineImportButton->Hide();
#endif

	BMessenger messager(this);
	BEntry entry(gProjectPath.GetFullPath());
	entry_ref ref;
	entry.GetRef(&ref);
	fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messager, &ref, B_FILE_NODE, true,
		new BMessage(M_OPEN_PROJECT));
	BString titleString(TR("Open Project"));
	titleString.Prepend("Paladin: ");
	fOpenPanel->Window()->SetTitle(titleString.String());

	fImportPanel = new BFilePanel(B_OPEN_PANEL, &messager, &ref, B_DIRECTORY_NODE,
		true, new BMessage(M_QUICK_IMPORT));
	titleString = TR("Choose Project Folder");
	titleString.Prepend("Paladin: ");
	fImportPanel->Window()->SetTitle(titleString.String());

	gSettings.Lock();
	int32 index = 0;
	while (gSettings.FindRef("recentitems", index++, &ref) == B_OK) {
		if (!BEntry(&ref).Exists()) {
			index--;
			gSettings.RemoveData("recentitems",index);
		} else
			fRecentProjectsListView->AddItem(new RefStringItem(ref),0);
	}
	gSettings.Unlock();

	// Alt + number opens that number project from the list
	int32 count = (fRecentProjectsListView->CountItems() > 9) ? 9 : fRecentProjectsListView->CountItems();
	for (int32 i = 0; i < count; i++) {
		BMessage* listMessage = new BMessage(M_OPEN_FROM_LIST);
		listMessage->AddInt32("index", i);
		AddShortcut('1' + i, B_COMMAND_KEY, listMessage);
	}

	fNewButton->MakeFocus(true);

	CenterOnScreen();
}
Пример #3
0
Файл: bb.c Проект: stroucki/bb
int bb(void)
{
    aa_gotoxy(context, 0, 0);
    introscreen();
    params = aa_getrenderparams();
    aa_render(context, params, 0, 0, 1, 1);
    font = uncompressfont( /*context->params.font */ &aa_font16);
    scenetimer = tl_create_timer();
    srand(time(NULL));
    if (stage != 1)
	finish_stuff = 1;
    do
	switch (stage) {
	default:
	case 1:
	    load_song("bb.s3m");
	    bbupdate();
	    starttime = endtime = TIME;

	    scene1();
	    scene3();
	    if (quitnow)
		goto quit;
	    vezen(&fk1, &fk2, &fk3, &fk4);
	    messager("FILIP KUPSA known as FK, Tingle Notions, Dawn Music\n"
		"birth: June 22 1979, Tabor, Czech Republic, sex: male\n"
		     "\n"
	     "1992 - Changed his piano for 386/mp.com/pc-speaker music\n"
		     "1993 - Got his first Sound Blaster\n"
		     "1995 - Changed his SB for a new GUS technology\n"
		     "1996 - Composed his first great hits\n"
		     "1996 - FAT recomposition made by Windows 95\n"
		     "1997 - Released his musac in BB\n"
		     "\n"
		     "1998 - Got retired\n"
		     "\n"
		     "Contact address: via KT");
	    devezen2();
	    scene4();
	    scene2();
	    if (quitnow)
		goto quit;
	    vezen(&ms1, &ms2, &ms3, &ms4);
	    messager("MOJMIR SVOBODA known as MS, TiTania, MSS, Bill\n"
		     "birth: ??, Tabor, Czech Republic, sex: ? male ?\n"
		     "\n"
		     "1993 - Installed Linux on his 386sx/25 + 40MB HDD\n"
		     "1994 - Removed Linux to make space for Doom\n"
		   "1995 - Reinstalled Linux on his 486Dx4/120 + 850MB\n"
		     "1996 - Removed Linux to make space for Windows 95\n"
		     "\n"
		     "1997 - Removed Windows 95 to make space for aalib\n"
		     "\n"
		     "Contact address: [email protected]");
	    devezen3();
	    scene8();
	    scene6();
	case 2:
	    if (quitnow)
		goto quit;
	    vezen(&kt1, &kt2, &kt3, &kt4);
	    messager("KAMIL TOMAN known as KT, Kato, Whale, Bart\n"
		 "birth: May 19 1979, Tabor, Czech Republic, sex: male\n"
		     "\n"
		     "1993 - Became a linux extremist\n"
		     "1993 - Successful attempt to establish a secret organization\n"
		     "       Commandline Brotherhood\n"
		     "1995 - Action 'koules' - a secret project to train brotherhood\n"
		     "       members - covered under a game design\n"
		     "\n"
		 "1998 - Heading a new wave of command line revolution\n"
		     "\n"
		     "Contact address: [email protected]");
	    bbupdate();
	    starttime = endtime = TIME;
	    devezen1();
	    if (quitnow)
		goto quit;
	    scene7();
	    if (quitnow)
		goto quit;
	    scene5();
	    if (quitnow)
		goto quit;
	    scene10();
	    vezen(&hh1, &hh2, &hh3, &hh4);
	    messager("JAN HUBICKA known as HH, Jahusoft, HuJaSoft, JHS, UNIX, Honza\n"
		  "birth: Apr 1 1978, Tabor, Czech Republic, sex: male\n"
		     "\n"
		     "1991 - Installed underground hackers OS Linux\n"
		     "1995 - Headed Action 'koules'\n"
		     "1996 - Famous troan XaoS to convert all windows instalations\n"
		     "       into Linux\n"
		     "\n"
		     "1998 - Secret plan to make `Text Windows` system to confuse users\n"
		 "2001 - Planning an assassination of dictator Bill G.\n"
		     "\n"
		     "Contact address: [email protected]");
	    devezen4();
	    if (quitnow)
		goto quit;
	    credits();
	    if (quitnow)
		goto quit;
	case 3:
	    if (loopmode)
		break;
	    credits2();
	}
    while (loopmode);
  quit:;
    aa_close(context);
    return (0);
}
Пример #4
0
Файл: main.cpp Проект: radi9/svm
int main() {

	BEGIN
		messager("loading training data, test data....", MEKEY);
		loadTrain(trainData, l_low, l_up);
		loadTest(testData);
		messager("done loading", MEKEY);
	END

	//initialize alpha values :
	//separate initialize the alpha values,
	//norAlpha and attAlhpa all 1

	messager("initialize optimized index table", MEKEY);
	messager("initialize all alpha to 0", MEKEY);
	messager("initialize all gradient to 0", MEKEY);
	messager("initialize all gradient bar to 0", MEKEY);

	BEGIN
	for (int i = 0; i < train_num; i++)
	{
		b.push_back(init_p);
		alpha.push_back(0.0);
		optimied_index[i] = false;
		if (encounter[i] == 1) {
			penalty.push_back(nor_penalty);
			pro.push_back(57378/62367);
		}
		else
		{
			penalty.push_back(att_penalty);
			pro.push_back(4989/62367);
		}
			grad.push_back(b[i]);
	}
	for (int i = 0; i < train_num; i++)
	{
		grad_bar.push_back(0); //no alpha is C at first, so all for zero
	}

	for(int i = 0; i < train_num; i++)
	{
		if(!is_lowerBound(i))
		{
			vector<double> column_i = get_Q(i);
			for(int j = 0; j < train_num; j++)
			{
				grad[j] += alpha[i] * column_i[j];
			}
			if(is_upperBound(i))
			{
				for(int j = 0; j < train_num; j++)
				{
					grad_bar[j] += penalty[i] * column_i[j];
				}
			}
		}
	}
	END

	/*
	 * iterator procedure
	 */
	//Values newAlpha;
	messager("modeling...", MEKEY);

	bool examALL = false;
	Values violating_pair;

	int iter = 0;
	while ( iter < train_num)
	{
		//test select WSS1, fixed l_up but not calculate all of it, it's too expense
		//test_ktt();

		cout << iter << endl;
		int i;
		int j;
		vector<double> qColu_i;
		vector<double> qColu_j;

//		if(iter%1000 == 0)
//		{
//			do_shrinking();
//		}

		if(selectWSS(i, j, violating_pair))
		{
			updateGrad();
			active_size = train_num;
			cout << "finished optimized" << endl;
			break;
		}
		else
		{
			qColu_i = get_Q(i);
			qColu_j = get_Q(j);
			update_alpha(violating_pair, i, j, qColu_i, qColu_j);
			updateGrad();
		}
		iter++;
	}
	int count = 0;
	for(int i = 0; i < alpha.size(); i ++)
	{
		if(alpha[i] != 0)
		{
			cout << "not zero alpha " << alpha[i] << "grad : " << grad[i] << endl;
		}
	}
	messager("alpha not zero", count, MEKEY);
	return 0;
}