Graph_disp::Graph_disp(const sf::VideoMode & mode, const int size_request, const sf::ContextSettings & context_settings): SFMLWidget(mode, size_request, context_settings), draw_cursor_flag(true), draw_axes_flag(true), use_orbit_cam(true), cam_light(glm::vec3(1.0f), 0.2f, glm::vec3(0.0f), 1.0f, 0.5f, 0.0f), dir_light(glm::vec3(0.5f), 0.2f, glm::vec3(-1.0f)), bkg_color(0.25f, 0.25f, 0.25f), ambient_color(0.4f, 0.4f, 0.4f), _cam(glm::vec3(0.0f, -10.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)), _orbit_cam({10.0f, 0.0f, (float)M_PI / 2.0f}), _scale(1.0f), _perspective(1.0f), _active_graph(nullptr) { // All OpenGL initialization has to wait until the drawing context actually exists // we do this in the initialize method // connect it to the draw signal, to be run only on the first drawing request _draw_connection = signal_draw().connect(sigc::mem_fun(*this, &Graph_disp::initiaize)); // connect event signals signal_size_allocate().connect(sigc::mem_fun(*this, &Graph_disp::resize)); signal_key_press_event().connect(sigc::mem_fun(*this, &Graph_disp::key_press)); // input is checked every 10ms Glib::signal_timeout().connect(sigc::mem_fun(*this, &Graph_disp::input), 10); set_can_focus(); set_can_default(); }
MachineListScrolledWindow::MachineListScrolledWindow(Gtk::Window &parent) : mpMachineListViewWithPopup(Gtk::manage(new MachineListViewWithPopup(parent))), m_width(0), m_height(0) { set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); add(*mpMachineListViewWithPopup); signal_size_allocate().connect(sigc::mem_fun(*this, &MachineListScrolledWindow::OnSizeAllocate)); }
Simple::Simple(): m_rotate_object(0), m_zoom_object(0) { m_rect = Papyrus::Rectangle::create( ); m_drawables[0] = m_rect; m_circle = Papyrus::Circle::create( ); m_drawables[1] = m_circle; m_text = Papyrus::Text::create( ); m_drawables[2] = m_text; m_lines = Papyrus::Polyline::create( ); m_drawables[3] = m_lines; m_polygon = Papyrus::Polygon::create( ); m_drawables[4] = m_polygon; m_png = Papyrus::Image::create( ); m_drawables[5] = m_png; m_drawables[6] = m_viewport.canvas(); set_title("Papyrus Group Transformation Demo"); m_vbox.set_border_width(12); m_frame.set_shadow_type(Gtk::SHADOW_IN); m_slider.set_range(0, ROTATE_MAX); m_slider.set_increments(M_PI/8.0, M_PI/8.0); m_zoom.set_range(0.1, 4.0); m_zoom.set_increments(0.25, 0.25); m_zoom.set_value(1.0); m_viewport.set_size_request(INITIAL_SIZE, INITIAL_SIZE); adjust_canvas(INITIAL_SIZE, INITIAL_SIZE); // This is the method that demonstrates the Papyrus objects draw_scene(); m_frame.add(m_viewport); m_vbox.pack_start(m_frame); m_slider.set_draw_value(false); m_slider.signal_value_changed().connect(sigc::mem_fun(*this, &Simple::slider_changed)); m_vbox.pack_start(*Gtk::manage(new Gtk::Label("Rotate")), Gtk::PACK_SHRINK); m_vbox.pack_start(m_slider, Gtk::PACK_SHRINK); m_animate.set_label("Animate Rotation"); m_animate.signal_toggled().connect(sigc::mem_fun(*this, &Simple::animate_toggled)); m_vbox.pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_SHRINK); m_vbox.pack_start(m_animate, Gtk::PACK_SHRINK); m_zoom.signal_value_changed().connect(sigc::mem_fun(*this, &Simple::zoom_changed)); m_vbox.pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_SHRINK); m_vbox.pack_start(*Gtk::manage(new Gtk::Label("Zoom")), Gtk::PACK_SHRINK); m_vbox.pack_start(m_zoom, Gtk::PACK_SHRINK); m_vbox.pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_SHRINK); Gtk::RadioButtonGroup button_group1, button_group2; Gtk::RadioButton* radio_button; Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); m_vbox.pack_start(*hbox); Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox()); hbox->pack_start(*vbox); vbox->pack_start(*Gtk::manage(new Gtk::Label("Rotation Object"))); radio_button = Gtk::manage(new Gtk::RadioButton(button_group1, "Rectangle")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_rotate_object_changed), 0)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group1, "Circle")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_rotate_object_changed), 1)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group1, "Text")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_rotate_object_changed), 2)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group1, "Lines")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_rotate_object_changed), 3)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group1, "Polygon")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_rotate_object_changed), 4)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group1, "Image")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_rotate_object_changed), 5)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group1, "Canvas")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_rotate_object_changed), 6)); vbox->pack_start(*radio_button); vbox = Gtk::manage(new Gtk::VBox()); hbox->pack_start(*vbox); vbox->pack_start(*Gtk::manage(new Gtk::Label("Zoom Object"))); radio_button = Gtk::manage(new Gtk::RadioButton(button_group2, "Rectangle")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_zoom_object_changed), 0)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group2, "Circle")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_zoom_object_changed), 1)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group2, "Text")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_zoom_object_changed), 2)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group2, "Lines")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_zoom_object_changed), 3)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group2, "Polygon")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_zoom_object_changed), 4)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group2, "Image")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_zoom_object_changed), 5)); vbox->pack_start(*radio_button); radio_button = Gtk::manage(new Gtk::RadioButton(button_group2, "Canvas")); radio_button->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &Simple::on_zoom_object_changed), 6)); vbox->pack_start(*radio_button); signal_size_allocate().connect(sigc::mem_fun(*this, &Simple::on_sig_size_allocate)); add(m_vbox); m_vbox.show_all(); show(); }