コード例 #1
0
void SaveAuthorController::onStart(){
	Controller::onStart();

    int rc;
	while((rc = gtk_dialog_run(GTK_DIALOG(getSceneRoot()))) == GTK_RESPONSE_OK){
		string firstName = gtk_entry_get_text(GTK_ENTRY(m_firstNameEntry));
		string middleName = gtk_entry_get_text(GTK_ENTRY(m_middleNameEntry));
		string lastName = gtk_entry_get_text(GTK_ENTRY(m_lastNameEntry));

		if(firstName == "" || lastName == ""){
            GtkWidget* dialog = getSceneObj("errorDialog");
            gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog),"<b>First name and last name cannot be empty.</b>");
			gtk_dialog_run(GTK_DIALOG(dialog));
            gtk_widget_hide(dialog);
		} else {
			m_author->getDirty()
					->putExtra("first_name",firstName)
					->putExtra("middle_name",middleName)
					->putExtra("last_name",lastName);

			m_author->saveRow();
			break;
		}
	}
	finish();
}
コード例 #2
0
    /// Override original method since it seems to adjust the clipping planes in a weird manner.
    /// Maybe using a screen-space projection or whatever.
    virtual void adjustCameraClippingPlanes()
    {
        SoCamera * camera = getCamera();
        if (!camera)
            return;

        SoGetBoundingBoxAction clipbox_action(getViewportRegion());
        clipbox_action.apply(getSceneRoot());

        SbBox3f bbox = clipbox_action.getBoundingBox();

        if (bbox.isEmpty())
            return;

        SbSphere bSphere;
        bSphere.circumscribe(bbox);

        SbVec3f forward;
        camera->orientation.getValue().multVec(SbVec3f(0,0,-1), forward);

        float denumerator = forward.length();
        float numerator = (bSphere.getCenter() - camera->position.getValue()).dot(forward);
        float distToCenter = (forward * (numerator / denumerator)).length();

        float farplane = distToCenter + bSphere.getRadius();

        // if scene is behind the camera, don't change the planes
        if (farplane < 0) return;

        float nearplane = distToCenter - bSphere.getRadius();

        if (nearplane < (0.001 * farplane)) nearplane = 0.001 * farplane;

        camera->nearDistance = nearplane;
        camera->farDistance = farplane;
    }