Exemplo n.º 1
0
void mouse(int button, int state, int x, int y)
{
	switch (button) {
	case GLUT_LEFT_BUTTON:
		if (state == GLUT_DOWN) {
			resetCount();
			dm = DrawXOY;

			glutPostRedisplay();
			glutSwapBuffers();
		}
		break;
	case GLUT_MIDDLE_BUTTON:
		if (state == GLUT_DOWN) {
			resetCount();
			dm = DrawXOZ;

			glutPostRedisplay();
			glutSwapBuffers();
		}
		break;
	case GLUT_RIGHT_BUTTON:
		if (state == GLUT_DOWN) {
			resetCount();
			dm = DrawYOZ;

			glutPostRedisplay ( );
			glutSwapBuffers ( );
		}
		break;
	default:
		break;
	}
}
Exemplo n.º 2
0
void ewol::compositing::Drawing::lineTo(const vec3& _dest) {
	resetCount();
	internalSetColor(m_color);
	//EWOL_VERBOSE("DrawLine : " << m_position << " to " << _dest);
	if (m_position.x() == _dest.x() && m_position.y() == _dest.y() && m_position.z() == _dest.z()) {
		//EWOL_WARNING("Try to draw a line width 0");
		return;
	}
	//teta = tan-1(oposer/adjacent)
	float teta = 0;
	if (m_position.x() <= _dest.x()) {
		teta = atan((_dest.y()-m_position.y())/(_dest.x()-m_position.x()));
	} else {
		teta = M_PI + atan((_dest.y()-m_position.y())/(_dest.x()-m_position.x()));
	}
	if (teta < 0) {
		teta += 2*M_PI;
	} else if (teta > 2*M_PI) {
		teta -= 2*M_PI;
	}
	//EWOL_DEBUG("teta = " << (teta*180/(M_PI)) << " deg." );
	float offsety = sin(teta-M_PI/2) * (m_thickness/2);
	float offsetx = cos(teta-M_PI/2) * (m_thickness/2);
	setPoint(vec3(m_position.x() - offsetx, m_position.y() - offsety, m_position.z()) );
	setPoint(vec3(m_position.x() + offsetx, m_position.y() + offsety, m_position.z()) );
	setPoint(vec3(_dest.x()      + offsetx, _dest.y()      + offsety, m_position.z()) );
	
	setPoint(vec3(_dest.x()      + offsetx, _dest.y()      + offsety, _dest.z()) );
	setPoint(vec3(_dest.x()      - offsetx, _dest.y()      - offsety, _dest.z()) );
	setPoint(vec3(m_position.x() - offsetx, m_position.y() - offsety, _dest.z()) );
	// update the system position :
	m_position = _dest;
}
Exemplo n.º 3
0
void cAlarmData::setTime(OsTime now)
{
   // For alarm filtering; if "now" is newer than the threshold, reset counts
   if (now-lastTime > TIME_THRESH_OS)
   {
      resetCount();
   };
   lastTime=now;
}
Exemplo n.º 4
0
void ewol::compositing::Drawing::rectangle(const vec3& _dest) {
	resetCount();
	internalSetColor(m_color);
	/* Bitmap position
	 *      xA     xB
	 *   yC *------*
	 *      |      |
	 *      |      |
	 *   yD *------*
	 */
	float dxA = m_position.x();
	float dxB = _dest.x();
	if (dxA > dxB) {
		// inverse order : 
		float tmp = dxA;
		dxA = dxB;
		dxB = tmp;
	}
	float dyC = m_position.y();
	float dyD = _dest.y();
	if (dyC > dyD) {
		// inverse order : 
		float tmp = dyC;
		dyC = dyD;
		dyD = tmp;
	}
	if (true == m_clippingEnable) {
		if (dxA < m_clippingPosStart.x()) {
			dxA = m_clippingPosStart.x();
		}
		if (dxB > m_clippingPosStop.x()) {
			dxB = m_clippingPosStop.x();
		}
		if (dyC < m_clippingPosStart.y()) {
			dyC = m_clippingPosStart.y();
		}
		if (dyD > m_clippingPosStop.y()) {
			dyD = m_clippingPosStop.y();
		}
	}
	if(    dyC >= dyD
	    || dxA >= dxB) {
		return;
	}
	setPoint(vec3(dxA, dyD, 0) );
	setPoint(vec3(dxA, dyC, 0) );
	setPoint(vec3(dxB, dyC, 0) );

	setPoint(vec3(dxB, dyC, 0) );
	setPoint(vec3(dxB, dyD, 0) );
	setPoint(vec3(dxA, dyD, 0) );
}
Exemplo n.º 5
0
 MockTestResult(TestOutput& p) :
     TestResult(p)
 {
     resetCount();
 }
Exemplo n.º 6
0
void main(){

	//Control LEDs

	P1_5=0x00;
	P1_4=0x00;
	P1_3=0x00;
	P1_2=0x00;
	P1_1=0x00;
	P1_0=0xff; // Ready Status

	//Byte LEDs


	P0_0 = 0x00;
	P0_1 = 0x00;
	P0_2 = 0x00;
	P0_3 = 0x00;
	P0_4 = 0x00;
	P0_5 = 0x00;
	P0_6 = 0x00;
	P0_7 = 0x00;




	while(1){

		if(P3_3 == 0x00 && byteLock <= 2){
			currentKey = 1;
			inputByte();

		}else if(P3_4 == 0x00 && byteLock <= 2){
			currentKey = 0;
			inputByte();

		}else if(P3_6 == 0x00 && byteCount >= 8){
			byteCount = 10; //Enter
			P1_1=0xff; // busy status on
			if(P1_2==0x00){
				P1_2=0xff; // byte A ready
				byteLock = 1;
				resetCount();

			}else if(byteLock==1){
				P1_3=0xff; // byte B ready
				byteLock = 2;
				resetCount();

			}else if(byteLock==2){
				P1_4=0xff; // byte C ready
				resetCount();
			}

		}else if(P3_5 == 0x00 && byteCount == 0){

			inputByte();

		}else{
			P1_1=0x00; // busy status off
			db = 0;
		}



	}
}
Exemplo n.º 7
0
void keyboard (unsigned char key, int x, int y)
{
	switch (key) {
	case (27):
		cleanJulia();
		exit(0);
	case ('w'):
		if (eye_z >= 256.) {
			eye_x -= 1.0;
			eye_z -= 1.0;
		}
		break;
	case ('x'):
		if (eye_z <= 512.) {
			eye_x += 1.0;
			eye_z += 1.0;
		}
		break;
	case ('a'):
		rotate_y_angle += 0.5;
		if (rotate_y_angle > 360.) {
			rotate_y_angle -= 360.0;
		}
		break;
	case ('d'):
		rotate_y_angle -= 0.5;
		if (rotate_y_angle < 0.) {
			rotate_y_angle += 360.0;
		}
		break;
	case ('q'):
		rotate_x_angle += 0.5;
		if (rotate_x_angle > 360.) {
			rotate_x_angle -= 360.0;
		}
		break;
	case ('e'):
		rotate_x_angle -= 0.5;
		if (rotate_x_angle < 0.) {
			rotate_x_angle += 360.;
		}
		break;
	case ('z'):
		rotate_z_angle += 0.5;
		if (rotate_z_angle > 360.) {
			rotate_z_angle -= 360.;
		}
		break;
	case ('c'):
		rotate_z_angle -= 0.5;
		if (rotate_z_angle < 0.0) {
			rotate_z_angle += 360.0;
		}
		break;
	case ('s'):
		resetCount();
		dm = DrawAll;
		break;
	default:
		break;
	}
}
Exemplo n.º 8
0
void ewol::compositing::Drawing::circle(float _radius, float _angleStart, float _angleStop) {
	resetCount();
	
	if (_radius<0) {
		_radius *= -1;
	}
	_angleStop = _angleStop-_angleStart;
	
	
	int32_t nbOcurence = _radius;
	if (nbOcurence < 10)
	{
		nbOcurence = 10;
	}
	
	// display background :
	if (m_colorBg.a()!=0) {
		internalSetColor(m_colorBg);
		for (int32_t iii=0; iii<nbOcurence; iii++) {
			setPoint(vec3(m_position.x(),
			              m_position.y(),
			              0) );
			
			float angleOne = _angleStart + (_angleStop* iii / nbOcurence) ;
			float offsety = sin(angleOne) * _radius;
			float offsetx = cos(angleOne) * _radius;
			
			setPoint(vec3(m_position.x() + offsetx,
			              m_position.y() + offsety,
			              0) );
			
			float angleTwo = _angleStart + (_angleStop* (iii+1) / nbOcurence) ;
			offsety = sin(angleTwo) * _radius;
			offsetx = cos(angleTwo) * _radius;
			
			setPoint(vec3(m_position.x() + offsetx,
			              m_position.y() + offsety,
			              0) );
		}
	}
	
	// show if we have a border :
	if(    m_thickness == 0
	    || m_color.a() == 0) {
		return;
	}
	internalSetColor(m_color);
	for (int32_t iii=0; iii<nbOcurence; iii++) {
		
		float angleOne =  _angleStart + (_angleStop* iii     / nbOcurence) ;
		float offsetExty = sin(angleOne) * (_radius+m_thickness/2);
		float offsetExtx = cos(angleOne) * (_radius+m_thickness/2);
		float offsetInty = sin(angleOne) * (_radius-m_thickness/2);
		float offsetIntx = cos(angleOne) * (_radius-m_thickness/2);
		
		float angleTwo =  _angleStart + (_angleStop*  (iii+1) / nbOcurence );
		float offsetExt2y = sin(angleTwo) * (_radius+m_thickness/2);
		float offsetExt2x = cos(angleTwo) * (_radius+m_thickness/2);
		float offsetInt2y = sin(angleTwo) * (_radius-m_thickness/2);
		float offsetInt2x = cos(angleTwo) * (_radius-m_thickness/2);
		
		setPoint(vec3(m_position.x() + offsetIntx,  m_position.y() + offsetInty,  0));
		setPoint(vec3(m_position.x() + offsetExtx,  m_position.y() + offsetExty,  0));
		setPoint(vec3(m_position.x() + offsetExt2x, m_position.y() + offsetExt2y, 0));
		
		setPoint(vec3(m_position.x() + offsetExt2x, m_position.y() + offsetExt2y, 0));
		setPoint(vec3(m_position.x() + offsetInt2x, m_position.y() + offsetInt2y, 0));
		setPoint(vec3(m_position.x() + offsetIntx,  m_position.y() + offsetInty,  0));
	}
}