Exemplo n.º 1
0
void Sted::Handle (Event& e) {
    if (e.eventType == KeyEvent) {
        if (e.len != 0) {
            char c = e.keystring[0];

            switch (c) {
            case '\010':
            case '\177':
                if (editor->Dot() != editor->Mark()) {
                    editor->DeleteSelection();
                } else {
                    editor->DeleteText(-1);
                }
                break;
            case '\015':
                InsertChar('\n');
                break;
            default:
                if (!iscntrl(c)) {
                    InsertChar(c);
                }
                break;
            }
        }
    } else if (e.eventType == DownEvent) {
        GetRelative(e.x, e.y, editor);
        editor->Select(editor->Locate(e.x, e.y));
        do {
            editor->ScrollToView(e.x, e.y);
            editor->SelectMore(editor->Locate(e.x, e.y));
            Poll(e);
            GetRelative(e.x, e.y, editor);
        } while (e.leftmouse);
    }
}
Exemplo n.º 2
0
void Sted::InsertDialog (Interactor* dialog) {
    World* world = GetWorld();

    Coord x, y;
    Align(Center, 0, 0, x, y);
    GetRelative(x, y, world);

    world->InsertTransient(dialog, this, x, y, Center);
}
Exemplo n.º 3
0
// Function to receive and screen the co-ords of the joints
void oscKinect::parseJoints(){
	float X = 0;
	float Y = 0;
	float Z = 0;
	int Joint = -1;
	
	while ( receiver.hasWaitingMessages() ) {
		
		// get the next message
		ofxOscMessage m;
		receiver.getNextMessage(&m);
		
		// look for the /joint message
		if (m.getAddress() == "/joint")
		{
			// arguments are s i f f f
			// s = string JointName
			// i = int userID
			// f = float X-coord
			// f = float Y-coord
			// f = float Z-coord
			
			// get the name of the joint
			joint = m.getArgAsString( 0 );
			userID = m.getArgAsInt32( 1 );
			
			X = m.getArgAsFloat(2);
			Y = m.getArgAsFloat(3);
			Z = m.getArgAsFloat(4);
			
			Joint = mapJointToInt(joint);
			
			if (Joint >= 0)
			{
				
			// Get Absolute measurements
			GetAbsolute(Joint, X, Y, Z);
			
			// Get Relative measurements
			GetRelative(Joint);
			
			// Get Velocity measurements
			// GetVelocity(Joint);
			
			// Get Accn
			// GetAcceleration(Joint);
				
			if ((Joint == R_HAND))
			{
				ArmLength = 1.0;
				// ArmLength = (pow(pow( (double)Coords[R_SHOULDER][X_dim]-(double)Coords[R_ELBOW][X_dim], (double)2 ) + pow((double)Coords[R_SHOULDER][Y_dim]-(double)Coords[R_ELBOW][Y_dim], (double)2) + pow((double)Coords[R_SHOULDER][Z_dim]-(double)Coords[R_ELBOW][Z_dim], (double)2), (double)0.5)) + (pow(pow((double)Coords[R_HAND][X_dim]-(double)Coords[R_ELBOW][X_dim], (double)2) + pow((double)Coords[R_HAND][Y_dim]-(double)Coords[R_ELBOW][Y_dim], (double)2) + pow((double)Coords[R_HAND][Z_dim] - (double)Coords[R_ELBOW][Z_dim], (double)2), (double)0.5)) + (pow(pow((double)Coords[R_SHOULDER][X_dim]-(double)Coords[TORSO][X_dim], (double)2) + pow((double)Coords[R_SHOULDER][Y_dim]-(double)Coords[TORSO][Y_dim], (double)2) + pow((double)Coords[R_SHOULDER][Z_dim] - (double)Coords[TORSO][Z_dim], (double)2), (double)0.5));
			}
				
			}
		}
		else {
			// unrecognized message: display on the bottom of the screen
			string msg_string;
			msg_string = m.getAddress();
			msg_string += ": ";
			for ( int i=0; i<m.getNumArgs(); i++ )
			{
				// get the argument type
				msg_string += m.getArgTypeName( i );
				msg_string += ":";
				// display the argument - make sure we get the right type
				if( m.getArgType( i ) == OFXOSC_TYPE_INT32 )
					msg_string += ofToString( m.getArgAsInt32( i ) );
				else if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
					msg_string += ofToString( m.getArgAsFloat( i ) );
				else if( m.getArgType( i ) == OFXOSC_TYPE_STRING )
					msg_string += m.getArgAsString( i );
				else
					msg_string += "unknown";
			}
			// add to the list of strings to display
			msg_strings[current_msg_string] = msg_string;
			timers[current_msg_string] = ofGetElapsedTimef() + 5.0f;
			current_msg_string = ( current_msg_string + 1 ) % NUM_MSG_STRINGS;
			// clear the next line
			msg_strings[current_msg_string] = "";
		}

	}
}
Exemplo n.º 4
0
void Menu::Open() {
    IntCoord x, y;
    Align(align_, 0, 0, x, y);
    GetRelative(x, y);
    InsertBody(x, y - body_->GetShape()->height);
}