Ejemplo n.º 1
0
// Convert HLS to RGB.
/* static */ COLORREF MyGraph::HLStoRGB(WORD wH, WORD wL, WORD wS)
{
	_ASSERTE(0 <= wH  &&  240 >= wH  &&  "Illegal hue value");
	_ASSERTE(0 <= wL  &&  240 >= wL  &&  "Illegal lum value");
	_ASSERTE(0 <= wS  &&  240 >= wS  &&  "Illegal sat value");

	WORD wR(0);
	WORD wG(0);
	WORD wB(0);

	// Achromatic case.
	if (0 == wS) {
		wR = wG = wB = (wL * RGBMAX) / HLSMAX;

		if (UNDEFINED != wH) {
			_ASSERTE(! "ERROR");
		}
	}
	else {
		// Chromatic case.
		WORD Magic1(0);
		WORD Magic2(0);

		// Set up magic numbers.
		if (wL <= HLSMAX / 2) {
			Magic2 = (wL * (HLSMAX + wS) + (HLSMAX / 2)) / HLSMAX;
		}
		else {
			Magic2 = wL + wS - ((wL * wS) + (HLSMAX / 2)) / HLSMAX;
		}

		Magic1 = 2 * wL - Magic2;

		// Get RGB, change units from HLSMAX to RGBMAX.
		wR = (HueToRGB(Magic1, Magic2, wH + (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
		wG = (HueToRGB(Magic1, Magic2, wH)                * RGBMAX + (HLSMAX / 2)) / HLSMAX;
		wB = (HueToRGB(Magic1, Magic2, wH - (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
	}

	return RGB(wR,wG,wB);
}
Ejemplo n.º 2
0
void OpenSMOKE_Kinetics::GetDerivativesC(double T, double cTot, BzzMatrix *dRC, 
									   BzzVector &cRes, BzzVector &R)
{
	ChangeDimensions(NC,NC,dRC);
	BzzVector wR(NC);

	int *jD1 = jDir1.GetHandle();
	int *jD2 = jDir2.GetHandle();
	int *jD3 = jDir3.GetHandle();
	int *jD4 = jDir4.GetHandle();
	int *jD5 = jDir5.GetHandle();
	double *vD5 = valDir5.GetHandle();

	int *jIE1 = jInvEq1.GetHandle();
	int *jIE2 = jInvEq2.GetHandle();
	int *jIE3 = jInvEq3.GetHandle();
	int *jIE4 = jInvEq4.GetHandle();
	int *jIE5 = jInvEq5.GetHandle();
	double *vIE5 = valInvEq5.GetHandle();


	double dc,udc;
	int j,k,kd;

	mc = cRes;
	mR = R;

	mr = reactionRates->r;
	mrDirC = reactionRates->rDirC;
	mrInvC = reactionRates->rInvC;

	// derivata rispetto a ckd
	for(kd = 1;kd <= NC;kd++)
	{
		// if(kd==1) cout << "Jacobian evaluation" << endl;
		// Solo se la concentrazione ?praticamente nulla
		if(mc[kd] <= 1.e-100)
		{
			cRes = mc;
			dc = 1.e-10 + 1.e-12 * cRes[kd];
			udc = 3.e-8 * Max(cRes[kd],1./dc);
			udc = Max(udc,1./dc);
			udc = Max(udc,1.e-19);
			dc = Min(udc,.001 + .001 * cRes[kd]);
			cRes[kd] += dc;
			udc = 1. / dc;

			reactionRates->ComputeFromConcentrations(T, cRes, cTot, &wR);
		
			for(j = 1;j <= mc.Size();j++)
				(*dRC)[j][kd] = (wR[j] - mR[j]) * udc;
			for(k = 1;k <= numDir1[kd];k++)
				jD1++;
			for(k = 1;k <= numDir2[kd];k++)
				jD2++;
			for(k = 1;k <= numDir3[kd];k++)
				jD3++;
			for(k = 1;k <= numDir4[kd];k++)
				jD4++;
			for(k = 1;k <= numDir5[kd];k++)
				{jD5++;vD5++;}

			for(k = 1;k <= numInvEq1[kd];k++)
				jIE1++;
			for(k = 1;k <= numInvEq2[kd];k++)
				jIE2++;
			for(k = 1;k <= numInvEq3[kd];k++)
				jIE3++;
			for(k = 1;k <= numInvEq4[kd];k++)
				jIE4++;
			for(k = 1;k <= numInvEq5[kd];k++)
				{jIE5++;vIE5++;}
			continue;
		}

		cRes = mc;
		dc = (S1 - 1.) * mc[kd];
		if(dc == 0.) BzzError("TODO dc = 0. R derivatives");
		cRes[kd] += dc;
		udc = 1. / dc;

		// 1. CALCOLO DELLE REAZIONI DIRETTE E INVERSE
		reactionRates->rDirC = mrDirC;
		reactionRates->rInvC = mrInvC;		
		for(k = 1;k <= numDir1[kd];k++)
			reactionRates->rDirC[*jD1++] *= S1;
		for(k = 1;k <= numDir2[kd];k++)
			reactionRates->rDirC[*jD2++] *= S2;
		for(k = 1;k <= numDir3[kd];k++)
			reactionRates->rDirC[*jD3++] *= S3;
		for(k = 1;k <= numDir4[kd];k++)
			reactionRates->rDirC[*jD4++] *= SSQ;
		for(k = 1;k <= numDir5[kd];k++)
			reactionRates->rDirC[*jD5++] *= pow(S1,*vD5++);

		for(k = 1;k <= numInvEq1[kd];k++)
			reactionRates->rInvC[*jIE1++] *= S1;
		for(k = 1;k <= numInvEq2[kd];k++)
			reactionRates->rInvC[*jIE2++] *= S2;
		for(k = 1;k <= numInvEq3[kd];k++)
			reactionRates->rInvC[*jIE3++] *= S3;
		for(k = 1;k <= numInvEq4[kd];k++)
			reactionRates->rInvC[*jIE4++] *= SSQ;
		for(k = 1;k <= numInvEq5[kd];k++)
			reactionRates->rInvC[*jIE5++] *= pow(S1,*vIE5++);

		// 2. CONTRIBUTI DALLE REAZIONI CON TERZO CORPO
		thirdBody(cRes, cTot, reactionRates->coeffM);

		// 3. CONTRIBUTI DERIVANTI DALLE REAZIONI DI FALLOFF
		fallOff(T, reactionRates->coeffM, reactionRates->k1, reactionRates->k2,
		       reactionRates->logFcent, reactionRates->coeffFallOff);
  
		// 4. ASEMBLAGGIO DEI DIVERSI CONTRIBUTI
		reactionsWithEquilibrium(reactionRates->rDirC, reactionRates->rInvC, reactionRates->uKeq, reactionRates->r);
		reactionsWithThirdBody(reactionRates->coeffM, reactionRates->r);
		//reactionsWithFallOff(reactionRates->coeffFallOff, reactionRates->r);
		
		for(j = 1;j <= NR;j++)
			reactionRates->r[j] *= reactionRates->coeffFallOff[j];

		// 5. COSTRUZIONE DEI CONTRIBUTI PER LE SINGOLE SPECIE
		compositionReactionRates(reactionRates->r, &wR);


		//---------------------------------------------------------------------------
		// Calcolo dello Jacobiano
		//---------------------------------------------------------------------------
		Difference(&wR,mR);
		Product(udc,&wR);
		dRC->SetColumn(kd,wR);
	}

}
Ejemplo n.º 3
0
Archivo: Help.cpp Proyecto: cryham/cAmp
void cAmp::DrawHelpText()									//  help  //
{
	CFont* cf = cfont[view.cfH];
	int Fy = cf->Fy;
	int y = /*(yBpt+100 > view.ySize) ? yBpl :*/ yB_pt+Fy,
		x1,x2, xt, t = 20;
	cf->Fs[' '] = cf->Fs['0']/2;
	cf->dir = 1;

	#define  sc(a)		cf->StrCopy(a)
	#define  wr(x,y)	cf->Write(x,y)
	#define  wR(x,y)	cf->Write(x,y);  cf->Write(x,y)
	#define  clr(r,g,b)  cf->Fclr = D3DXCOLOR(r,g,b,1)
	#define  X(a1,a2)  x1 = a1;  xt = x1+t;  x2 = x1 + a2;
	#pragma warning(disable: 4305)  // clr(0.7f

	clr(0.7,0.7,0.7);    sc("Keyboard help");  wr(20,y);  //y+=Fy;
	clr(0.8,0.8,0.9);    cf->Format("Page: %s %d/%d %s", hlpPg==0?"  ":"<", hlpPg+1,HelpPages, hlpPg==HelpPages-1?"  ":">");
	wr(view.xSize-110,y);  y+=Fy*3/2;	clr(1,1,1);
	
	sc(HPnames[hlpPg]);  int o=cf->GetWidth(); //center
	wr(view.xSize/2-o/2,y);  y = yB_pt+5*Fy;
	#define dark()  clr(0.75,0.85,0.95)
	
	switch (hlpPg)
	{
	case 0:  X(20,35);		//  Player basic
		clr(0.3,0.7,0.7);
		sc("Enter, RMB    Play from cursor  |>");	wR(x1,y);  y+=Fy*4/2;  clr(0.7,0.95,1);
		sc("Z");	wr(x1,y);  sc("Play     |>");	wr(x2,y);  y+=Fy;
		sc("X");	wr(x1,y);  sc("Pause   ||");	wr(x2,y);  y+=Fy;
		sc("C");	wr(x1,y);  sc("Stop    []");	wr(x2,y);  y+=Fy*3/2;  clr(0.95,1,1);
		
		sc("A");	wr(x1,y);  sc("Previous  |<");	wr(x2,y);  y+=Fy;
		sc("S");	wr(x1,y);  sc("Next        >|");	wr(x2,y);  y+=Fy;	dark();
			sc("alt- dec/inc playing track rating");	wr(xt,y);  y+=Fy;
			sc("ctrl- play prev/next playlist");		wr(xt,y);  y+=Fy*5/2;  clr(0.9,0.95,1);

		X(20,80,40);
		sc("Left   Q");		wr(x1,y);  sc("Backward  <<");	wr(x2,y);  y+=Fy;
		sc("Right  W");		wr(x1,y);  sc("Forward    >>");	wr(x2,y);  y+=Fy;    dark();
			sc("shift- small  ctrl- big");					wr(xt,y);  y+=Fy*2;  clr(0.8,0.8,1);
		X(20,100,40);
		sc("alt-Left   Q");	wr(x1,y);  sc("Volume Down  v");wr(x2,y);  y+=Fy;
		sc("alt-Right  W");	wr(x1,y);  sc("Volume Up  ^");	wr(x2,y);  y+=Fy*5/2;  clr(0.95,0.8,1.0);
		
		X(20,35,40);
		sc("R");	wr(x1,y);  sc("Repeat All    @A");		wr(x2,y);  y+=Fy;
		sc("1 T");	wr(x1,y);  sc("Repeat One  @1");		wr(x2,y);  y+=Fy*5/2;  clr(0.6,0.8,1.0);

		sc("F1");	wr(x1,y);  sc("show/hide Help");		wr(x2,y);  y+=Fy*2/2;
		x2=x1+60;	clr(0.3,0.6,0.8);
		sc("ctrl-F1");	wR(x1,y);  sc("Global Keys config");	wR(x2,y);  y+=Fy;
		sc("ctrl-F2");	wR(x1,y);  sc("Player Settings");		wR(x2,y);  y+=Fy;
		break;

	case 1:  t=15; X(20,50);		//  Mouse
		clr(0.4,0.8,0.8);
		sc("Left");									wR(x1,y);  y+=Fy;  clr(1,1,1);
		sc("at player-  change track position (seek)");	wr(xt,y);  y+=Fy*3/2;
		sc("at tabs-  change Tab");					wr(xt,y);  y+=Fy;
			sc("alt-  move Tab");					wr(xt+t,y);  y+=Fy*2/2;  dark();
			sc("dn/up buttons - change offset");	wr(xt+t,y);  y+=Fy;
			sc("ctrl- tab rows  shift- tab cols");	wr(xt+t,y);  y+=Fy*2;  clr(1,1,1);

		sc("at playlist-  pick track (cursor)");	wr(xt,y);  y+=Fy;  dark();
			sc("ctrl-  select/unselect one");		wr(xt+t,y);  y+=Fy;  clr(0.6,0.8,1.0);
			sc("shift-  select range");				wr(xt+t,y);  y+=Fy;
			sc("shift-ctrl-  unselect range");		wr(xt+t,y);  y+=Fy*2/2;  clr(1,0.9,0.8);
			sc("alt-  Move track/selection");		wr(xt+t,y);  y+=Fy*4/2;  clr(0.4,0.7,1.0);
			//  slider pls |

		sc("Right");								wR(x1,y);  y+=Fy;  clr(1,1,1);
		sc("at playlist-  Play track  |>");			wr(xt,y);  y+=Fy;  dark();
		sc("at player-   change rating");			wr(xt,y);  y+=Fy*3/2;  clr(0.4,0.6,1);
			sc("shift-         Move Window +");		wR(xt,y);  y+=Fy;
			sc("shift-ctrl-  Resize Window []");	wR(xt,y);  y+=Fy*5/2;  clr(0.7,0.6,1.0);
		
		sc("Wheel");								wR(x1,y);  y+=Fy;    clr(0.8,0.8,1);
		sc("at player-  change volume  ^v");		wr(xt,y);  y+=Fy;
		sc("at playlist-  scroll");					wr(xt,y);  y+=Fy;    dark();
			sc("shift- less  ctrl- more");			wr(xt+t,y);  y+=Fy*2;  clr(0.7,0.5,0.5);

		sc("Middle");								wR(x1,y);			 //clr(1,0.9,0.8);
		sc("joy scroll list");						wR(x2,y);  y+=Fy;    clr(0.9,0.8,1);
			sc("shift- change Visualization height");	wr(xt,y);  y+=Fy*2;  clr(0.35,0.5,0.8);
		break;

	case 2:  X(20,80);		//  Playlist basic
		sc("Up,Down");		wr(x1,y);
		sc("move cursor,  ctrl- x8");			wr(x2,y);  y+=Fy;	dark();
			sc("alt- move 1 track up/dn");		wr(xt,y);  y+=Fy;
			sc("alt-shift- to Top  alt-ctrl- to End");	wr(xt,y);  y+=Fy*3/2;	clr(1,1,1);
	
		sc("PgUp,PgDn");	wr(x1,y);
		sc("move page/4,  ctrl- page");						wr(x2,y);  y+=Fy;		dark();
			sc("alt- offset page  alt-ctrl- offset x8");	wr(xt,y);  y+=Fy*3/2;	clr(1,1,1);
		
		sc("Home,End");		wr(x1,y);
		sc("prev/next dir");						wr(x2,y);  y+=Fy;		dark();
			sc("shift- move to begin/end of dir");	wr(xt,y);  y+=Fy;		
			sc("ctrl- of view  alt- of list");		wr(xt,y);  y+=Fy*5/2;	clr(1,1,1);

		X(20,80);  clr(0.85,0.8,1.0);
		sc("Space");		wr(x1,y);  sc("Unselect");					wr(x2,y);  y+=Fy;
		sc("Backspace");	wr(x1,y);  sc("move cursor to playing");	wr(x2,y);  y+=Fy;
			sc("ctrl- also change tab and center");	wr(xt,y);  y+=Fy*4/2;  clr(1,1,1);

		X(20,60);  clr(1,0.9,0.8);
		sc("Delete");		wr(x1,y);  sc("Delete track/selection");	wr(x2,y);  y+=Fy;  clr(1,0.8,0.6);
			sc("shift-");	wr(xt,y);  sc("Delete from Disk");			wr(x2,y);  y+=Fy;  clr(1,0.7,0.85);
			sc("ctrl-");	wr(xt,y);  sc("Clear playlist");			wr(x2,y);  y+=Fy*4/2;
	
		clr(0.7,0.7,1.0);
		sc("Insert");		wr(x1,y);
		sc("alt- Insert Directory at cursor");		wr(x2,y);  y+=Fy;		dark();
			sc("shift- at Top   ctrl- at End");		wr(xt,y);  y+=Fy*4/2;	clr(1,1,1);

		clr(0.4,0.63,0.85);
		sc("Drop  at playlist - insert at cursor");	wR(x1,y);  y+=Fy;  //dark();
			sc("shift- at Top   ctrl- at End");		wR(xt,y);  y+=Fy*2;	clr(1,1,1);
		break;

	case 3:  X(20,55);		//  Playlist advanced
		clr(0.25,0.2,0.3);
		sc("Num"); wR(x1+20,y);  clr(0.6,0.5,0.7);  y+=Fy;
		sc("-   -");	wR(x1,y);	sc("dec track Rating");		wR(x2,y);  y+=Fy;
		sc("=   +");	wR(x1,y);	sc("inc track Rating");		wR(x2,y);  y+=Fy;	clr(0.9,0.7,0.9);
			sc("at playing cursor  ctrl- at cursor");			wr(xt,y);  y+=Fy*3/2;	clr(0.7,0.5,0.8);
		sc("[    /");	wR(x1,y);	sc("Dec rating Filter (lower)");	wR(x2,y);  y+=Fy;
		sc("]    *");	wR(x1,y);	sc("Inc rating Filter");	wR(x2,y);  y+=Fy;	clr(0.9,0.7,0.9);
			sc("ctrl- upper Filter");							wr(xt,y);  y+=Fy*4/2;	clr(0.7,0.5,0.8);

		X(20,40);  clr(0.3,0.65,0.75);
		sc("\\");	wR(x1,y);	sc("inc Bookmark at cursor");	wR(x2,y);  y+=Fy;  clr(0.2,0.55,0.65);
		sc("  ctrl- dec   alt- playlist (tab)");		wR(x1,y);	y+=Fy*3/2;  clr(0.3,0.65,0.75);
		sc("/  .");	wR(x1,y);	sc("next/prev Bookmark in playlist or");	wR(x2,y);  y+=Fy;  clr(0.45,0.7,0.4);
		sc("next/prev Search result, when showing");	wR(x2,y);  y+=Fy*2;  clr(1,1,1);

		sc("D");	wr(x1,y);  clr(0.8,0.9,0.9);
		sc("Duplicate track");							wr(x2,y);  y+=Fy;		dark();
			sc("shift- at Top   ctrl- at End");			wr(xt,y);  y+=Fy*5/4;	clr(1,1,1);
		sc("H");	wr(x1,y);	sc("Hide directory -");	wr(x2,y);  y+=Fy;
		sc("J");	wr(x1,y);	sc("Show directory +");	wr(x2,y);  y+=Fy*2;
		break;

	case 4:  X(20,50);		//  Tabs, visual
		sc("Tab `");wr(x1,y);
		sc("Next/prev playlist Tab");			wr(x2,y);  y+=Fy;	dark();
			sc("ctrl-  row down/up");			wr(xt,y);  y+=Fy;	clr(0.7,0.75,0.8);
			sc("shift-  offset row down/up");	wr(xt,y);  y+=Fy;
			sc("ctrl-shift-  offset 1");		wr(xt,y);  y+=Fy*2;	clr(1,1,1);
		
		sc("N");	wr(x1,y);
			sc("add New Tab after current");		wr(x2,y);  y+=Fy;  dark();
			sc("ctrl- at End  shift- at Begin");	wr(xt,y);  y+=Fy;
			sc("alt- before current");				wr(xt,y);  y+=Fy*4/2;  clr(0.3,0.55,0.8);

		sc("F2");	wR(x1,y);  sc("Rename Tab");	wR(x2,y);  y+=Fy;  clr(1.0,0.85,0.75);
		sc("F8");	wr(x1,y);  sc("Close Tab");		wr(x2,y);  y+=Fy*5/2;  clr(0.7,0.7,0.8);

		X(20,35);			//  Player visual
		sc("O P");	wR(x1,y);  sc("prev/next Visualization");	wR(x2,y);  y+=Fy*3/2;  clr(0.8,0.9,1);
		
		sc("3");	wr(x1,y);  sc("show path, filename info");	wr(x2,y);  y+=Fy*4/2;	clr(0.6,0.75,0.9);
		
		sc("2");	wr(x1,y);  sc("change dir/path display");	wr(x2,y);  y+=Fy;
		sc("0");	wr(x1,y);  sc("draw rating on slider");		wr(x2,y);  y+=Fy*3/2;	clr(0.8,0.7,0.9);
		
		sc("4");	wr(x1,y);  sc("all playlists info");		wr(x2,y);  y+=Fy;
		sc("5");	wr(x1,y);  sc("filtered playlist info");	wr(x2,y);  y+=Fy*4/2;

		X(20,50);	clr(0.65,0.7,0.75);
		sc("I");	wr(x1,y);  sc("Frames per second display");		wr(x2,y);  y+=Fy;
		sc("Ctr-I");wr(x1,y);  sc("Time colors test");		wr(x2,y);  y+=Fy;	clr(1,1,1);
		break;

	case 5:  X(20,50);		//  Player functions
		sc("F4");	wr(x1,y);	sc("Save playlist (quick)");	wr(x2,y);  y+=Fy;
		sc("F5");	wr(x1,y);	sc("Reload playlist");			wr(x2,y);  y+=Fy;
		sc("ctrl-F5");	wr(x1,y);	sc("open playlist");		wr(x2,y);  y+=Fy*4/2;  clr(0.9,0.8,1);
		
		sc("F6");	wr(x1,y);	sc("Re-Insert directory at cursor");	wr(x2,y);  y+=Fy;	dark();
			sc("shift- at Top   ctrl- at End");				wr(xt,y);  y+=Fy*3/2;	clr(0.8,0.9,1);
		sc("U");	wr(x1,y);	sc("Update playlist (times)");	wr(x2,y);  y+=Fy*2;

		clr(0.7,0.55,0.8);
		sc("F10");	wR(x1,y);	sc("apply rating in playlist and save");	wR(x2,y);  y+=Fy;  clr(0.8,0.6,0.8);
		sc("F9");	wr(x1,y);	sc("apply rating to cur filename");			wr(x2,y);  y+=Fy;  //clr(0.8,0.6,0.8);
			sc("shift- in dir  ctrl- in playlist");							wr(x1+t,y);  y+=Fy*2;

		clr(0.45,0.7,0.4);
		sc("F3  F");	wR(x1,y);  sc("Search name");	wR(x2,y);  y+=Fy;
			sc("shift-  hide/show results");			wR(x1+t,y);  y+=Fy*2;	 clr(1,1,1);

		clr(0.6,0.8,0.7);
		sc("alt 1..8");  wr(x1,y);  sc("load View 1..8");	wR(x2+10,y);  y+=Fy;
		sc("ctrl 1..8");  wr(x1,y);  sc("save View 1..8");	wR(x2+10,y);  y+=Fy;
			sc("window position,size,visualization etc.");  wr(xt,y);  y+=Fy*2;

		clr(0.8,0.8,0.6);
		sc("F11");	wr(x1,y);  sc("Reload resources, check window");	wr(x2,y);  y+=Fy*2;
		
		clr(0.75,0.75,0.85);
		sc("F12");	wr(x1,y);  sc("Copy selected to other path");	wr(x2,y);  y+=Fy;
			sc("shift-  whole playlist   ctrl- all   alt- abort");	wr(xt,y);  y+=Fy*2;	 clr(1,1,1);
		break;
	}
}