コード例 #1
0
ファイル: vsr_interface.cpp プロジェクト: mantaraya36/vsr
    void Interface :: xfFrame( Frame * frame, double t){
		Pnt& tp = frame->pos();
		//Rot& tr = frame->rot();
		Vec tv ( tp );
		Vec sc = GL::project(tv[0], tv[1], tv[2], scene().xf);
        
		switch(keyboard.code){
			case 's': //scale
			{
                //printf("scale\n");s
                Vec tm1 = mouse.pos + mouse.drag - sc;
                Vec tm2 = mouse.pos - sc; 
				int neg = (tm1.norm() > tm2.norm()) ? -1 : 1; //Drag towards or away from element
				
				frame->dd( mouse.drag.norm()*t*neg );
				frame->dilate();
				break;
			}
			case 'g': //translate
			{
                //			tp = Op::sp(tp, Gen::trs(scene().mdc()*t));
                //cout << "g" << endl; 
				frame->dx() = mouse.dragCat * t;
				frame->move();
				break;
			}
			case 'r': //rotate about local line
			{
				frame->db() =  mouse.dragBivCat * t; //scene().mp().unit() ^ scene().md();
                //cout << t << endl; 
                //Biv b = mouse.dragBivCat * t; 
				//frame->rot( Gen::rot(b) * frame->rot() ); //spin();
                frame->spin();
				break;
			}
			case 'b': //boost by drag
			{
				break;
			}
			case 'a': //all transformations
			{
				//double neg = mouse.drag[0];
				break;
			}
			default:
			{
                toggleSelect(frame); 
                break;
			}
		}
		frame ->acc();
    }
コード例 #2
0
ファイル: keyboard.c プロジェクト: Flare183/dsorganize
char executeClick(int px, int py)
{
	if(py >= DEFAULT_TOP)
	{
		if(py <= DEFAULT_BOTTOM)
		{
			if(px >= INS_LEFT && px <= INS_RIGHT)
			{
				toggleIns();
			}

			if(px >= CTRL_LEFT && px <= CTRL_RIGHT)
			{
				toggleControl();
			}

			if(px >= SELECT_LEFT && px <= SELECT_RIGHT)
			{
				toggleSelect();
			}

			if(px >= CLEAR_LEFT && px <= CLEAR_RIGHT)
			{
				return CLEAR_KEY;
			}
		}

		return 0;
	}

	if(activeKeyboard() == KB_MESSAGEASE)
	{
		downX = px;
		downY = py;
		upX = px;
		upY = py;

		px -= 32;
		py -= 37;

		if(px >= 1 && py >= 1 && px <= 31 && py <= 31) // caps
		{
			toggleCaps();
			downX = 0;
			downY = 0;
		}

		if(px >= 1 && py >= 33 && px <= 31 && py <= 62) // shift
		{
			toggleShift();
			downX = 0;
			downY = 0;
		}

		if(px >= 1 && py >= 64 && px <= 31 && py <= 94) // special
		{
			toggleSpecial();
			downX = 0;
			downY = 0;
		}

		if(px >= 160 && py >= 1 && px <= 190 && py <= 31) // backspace
		{
			return translateCode(K_B, SYMBOLS);
		}

		if(px >= 160 && py >= 33 && px <= 190 && py <= 62) // return
		{
			return translateCode(K_R, SYMBOLS);
		}

		if(px >= 129 && py >= 1 && px <= 158 && py <= 31) // delete
		{
			return translateCode(K_D, SYMBOLS);
		}

		if(px >= 129 && py >= 33 && px <= 158 && py <= 62) // space
		{
			shift = 0;
			return translateCode(K_W, SYMBOLS);
		}

		if(px >= 129 && py >= 64 && px <= 158 && py <= 94) // number toggle
		{
			isNumbers = 1 - isNumbers;
			downX = 0;
			downY = 0;
		}

		curChar = 0;
		return 0;
	}

	py -= 37;

	if(py < 0)
		return 0;

	int tilex = 0;
	int tiley = py / 19;

	if(tiley < 0 || tiley > 4)
		return 0;

	switch(tiley)
	{
		case 0: // first row
			if(px < 13)
				return 0;
			px -= 13;
			tilex = px / 19;
			break;
		case 1: // second row
			if(px < 23)
				return 0;
			if(px >= 213 && px <= 242) // backspace
				return translateCode(K_B, SYMBOLS);

			px -= 23;
			tilex = px / 19;
			break;
		case 2: // third row
			if(px < 13)
				return 0;
			if(px >= 203 && px <= 242) // return
				return translateCode(K_R, SYMBOLS);

			px -= 13;
			tilex = px / 19;
			break;
		case 3: // fourth row
			if(px < 13)
				return 0;
			if(px < 42) // shift
			{
				toggleShift();
				curChar = 0;
				return 0;
			}

			px -= 42;
			tilex = px / 19;
			break;
		case 4: // fifth row
			if(px < 13)
				return 0;
			if(px >= 89 && px < 184) // space
				return translateCode(K_W, SYMBOLS);

			px -= 13;
			tilex = px / 19;
			break;
	}

	if(tilex < 0 || tilex > 11)
		return 0;

	char c = 0; // capture character.

	if(tiley == 0) // this is the numbers
	{
		if(shift == 1)
			c = translateCode(keyboard_Hit[tilex], SYMBOLS);
		else
			c = translateCode(keyboard_Hit[tilex], NUMBERS);
	}
	else // this is letters
	{
		if((caps == 0 && shift == 0) || (caps == 1 && shift == 1))
		{
			if(special == 0)
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],LOWERCASE);
			else
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],SPECIAL0);
		}
		else
		{
			if(special == 0)
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],UPPERCASE);
			else
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],SPECIAL1);
		}
	}

	if(c==DEL) // Return
	{
		// to ensure we dont lowercase on a delete
	}
	else if(c == CAP)
	{
		toggleCaps();
		curChar = 0;
		c = 0;
	}
	else if(c == SPL)
	{
		toggleSpecial();
		curChar = 0;
		c = 0;
	}
	else
	{
		shift = 0;
	}

	return c;
}