diff --git a/Makefile.am b/Makefile.am index 86fd685..051c4f5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -309,6 +309,7 @@ sgpemv2_SOURCES = \ src/gui_builder.cc \ src/holt_container_window.cc \ src/holt_widget.cc \ + src/jump_to_dialog.cc \ src/main.cc \ src/parse_opts.cc \ src/ready_queue_widget.cc \ @@ -327,6 +328,7 @@ noinst_HEADERS += \ src/graphical_preferences_editor.hh \ src/gui_builder.hh \ src/holt_widget.hh \ + src/jump_to_dialog.hh \ src/main.hh \ src/parse_opts.hh \ src/ready_queue_widget.hh \ @@ -346,6 +348,7 @@ glade_DATA = \ glade/add-resource-dialog.glade \ glade/add-thread-dialog.glade \ glade/configure-dialog.glade \ + glade/jump-to-dialog.glade \ glade/main-window.glade # ############################################################ diff --git a/glade/main-window.glade b/glade/main-window.glade index a401c52..a2828ec 100644 --- a/glade/main-window.glade +++ b/glade/main-window.glade @@ -1,451 +1,661 @@ - - - + + + - - SGPEMv2 - 800 - 600 - gtk-dialog-warning - - - True - - - True - - - True - _File - True - - - - - True - gtk-open - True - True - - - - - True - gtk-save - True - True - - - - - True - gtk-save-as - True - True - - - - - True - gtk-close - True - True - - - - - True - - - - - True - gtk-quit - True - True - - - - - - - - - True - _Edit - True - - - - - True - gtk-preferences - True - True - - - - - - - - - True - _View - True - - - - - True - Enable/disable threads visualization in Graphs - Show _Threads - True - - - - - True - Show/Hide holt graph window - Show _Holt Graph - True - - - - - - - - - True - _Simulation - True - - - - - True - gtk-media-play - True - True - - - - - True - False - gtk-media-pause - True - True - - - - - True - False - gtk-media-stop - True - True - - - - - - True - - - - - True - True - Continuous mode - True - - - - - - - - - True - _Help - True - - - - - True - gtk-about - True - True - - - - - - - - - False - - - - - True - GTK_TOOLBAR_BOTH - - - True - gtk-open - - - - - True - gtk-save - - - - - True - - - - - True - gtk-media-play - Start the simulation - - - - - True - False - gtk-media-pause - - - - - True - False - gtk-media-stop - - - - - True - - - - - True - Scheduling Policy - True - gtk-convert - - - - - True - - - - - True - Resource Scheduling - True - gtk-select-color - - - - - False - 1 - - - - - True - - - False - 3 - - - - - True - True - 1 - 200 - - - True - - - True - 0,000000 - 0,000000 - GTK_SHADOW_NONE - - - True - 0,000000 - 0,000000 - 12 - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_OUT - - - - - - - - - - True - 0,000000 - 0,000000 - 2 - <i>Schedulables</i> - True - - - label_item - - - - - False - - - - - True - 0,000000 - 0,000000 - GTK_SHADOW_NONE - - - True - 0,000000 - 0,000000 - 12 - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_OUT - - - True - True - - - - - - - - - True - 0,000000 - 0,000000 - 2 - <i>Resources</i> - True - - - label_item - - - - - False - - - - - False - False - - - - - True - True - GTK_POLICY_AUTOMATIC - - - - - - - - 2 - - - - - True - - - False - GTK_PACK_END - 2 - - - - - - - University of Padova, dept. of Pure and Applied Mathematics - An educational simulator for process scheduling policies in a monoprocessor computer. - SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under the terms of the GNU General Public License; for details see file COPYING contained in the source package. - Filippo Paparella <ironpipp@gmail.com> + + + SGPEMv2 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 800 + 600 + True + False + gtk-dialog-warning + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + False + 0 + + + + True + GTK_PACK_DIRECTION_LTR + GTK_PACK_DIRECTION_LTR + + + + True + _File + True + + + + + + + True + gtk-open + True + + + + + + True + gtk-save + True + + + + + + True + gtk-save-as + True + + + + + + True + gtk-close + True + + + + + + True + + + + + + True + gtk-quit + True + + + + + + + + + + True + _Edit + True + + + + + + + True + gtk-preferences + True + + + + + + + + + + True + _View + True + + + + + + + True + Enable/disable threads visualization in Graphs + Show _Threads + True + + + + + + True + Show/Hide holt graph window + Show _Holt Graph + True + + + + + + + + + + True + _Simulation + True + + + + + + + True + gtk-media-play + True + + + + + + True + False + gtk-media-pause + True + + + + + + True + False + gtk-media-stop + True + + + + + + + True + + + + + + True + gtk-jump-to + True + + + + + + True + + + + + + True + Continuous mode + True + True + + + + + + + + + + True + _Help + True + + + + + + + True + gtk-about + True + + + + + + + + + 0 + False + True + + + + + + True + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_BOTH + True + True + + + + True + gtk-open + True + True + False + + + False + True + + + + + + True + gtk-save + True + True + False + + + False + True + + + + + + True + True + True + True + + + False + False + + + + + + True + Start the simulation + gtk-media-play + True + True + False + + + False + True + + + + + + True + False + gtk-media-pause + True + True + False + + + False + True + + + + + + True + False + gtk-media-stop + True + True + False + + + False + True + + + + + + True + True + True + True + + + False + False + + + + + + True + Scheduling Policy + True + gtk-convert + True + True + False + + + False + False + + + + + + True + True + True + True + + + False + False + + + + + + True + Resource Scheduling + True + gtk-select-color + True + True + False + + + False + False + + + + + 0 + False + True + + + + + + True + True + + + 0 + False + True + GTK_PACK_END + + + + + + 1 + True + True + 200 + + + + True + + + + True + 0 + 0 + GTK_SHADOW_NONE + + + + True + 0 + 0 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_OUT + GTK_CORNER_TOP_LEFT + + + + + + + + + + + + True + <i>Schedulables</i> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 2 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + True + False + + + + + + True + 0 + 0 + GTK_SHADOW_NONE + + + + True + 0 + 0 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_OUT + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + + + + + + True + <i>Resources</i> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 2 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + True + False + + + + + False + False + + + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + + + + True + True + + + + + 0 + True + True + + + + + + True + False + 0 + + + 0 + False + True + + + + + + + + False + Application Name + University of Padova, dept. of Pure and Applied Mathematics + An educational simulator for process scheduling policies in a monoprocessor computer. + SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under the terms of the GNU General Public License; for details see file COPYING contained in the source package. + False + Filippo Paparella <ironpipp@gmail.com> Paolo Santi <psanti@studenti.math.unipd.it> Matteo Settenvini <matteo@member.fsf.org> Marco Trevisan <mtrevisa@studenti.math.unipd.it> Djina Verbanac <betalgez@yahoo.com> Luca Vezzaro <lvezzaro@studenti.math.unipd.it> - Giovanni Giacobbi <ggiacobb@studenti.math.unipd.it> + Giovanni Giacobbi <ggiacobb@studenti.math.unipd.it> Filippo Paparella <ironpipp@gmail.com> Paolo Santi <psanti@studenti.math.unipd.it> Matteo Settenvini <matteo@member.fsf.org> Marco Trevisan <mtrevisa@studenti.math.unipd.it> Djina Verbanac <betalgez@yahoo.com> Luca Vezzaro <lvezzaro@studenti.math.unipd.it> - translator-credits - - - True - 12 - - - - - - True - GTK_BUTTONBOX_END - - - False - GTK_PACK_END - - - - - + + + + + True + False + 12 + + + + + + + + True + GTK_BUTTONBOX_END + + + 0 + False + True + GTK_PACK_END + + + + + + diff --git a/src/gui_builder.cc b/src/gui_builder.cc index b9d29fb..7a452d1 100644 --- a/src/gui_builder.cc +++ b/src/gui_builder.cc @@ -31,6 +31,7 @@ #include "schedulables_tree_widget.hh" #include "simulation_widget.hh" #include "resources_widget.hh" +#include "jump_to_dialog.hh" #include @@ -75,7 +76,18 @@ GuiBuilder::on_edit_preferences_activate() // a refptr member data?) } +void +GuiBuilder::on_simulation_jump_to_activate() +{ + using Gnome::Glade::Xml; + + Glib::RefPtr jump_to_dialog_glade = Xml::create(GLADEDIR "/jump-to-dialog.glade"); + + JumpToDialog* jump_to_dialog = NULL; + jump_to_dialog_glade->get_widget_derived("JumpToDialog", jump_to_dialog); + jump_to_dialog->run(); +} void GuiBuilder::on_view_show_threads_activate() @@ -506,7 +518,10 @@ GuiBuilder::GuiBuilder(const std::string& gladefile) _refXml->get_widget("MenuItem.Edit.Preferences", edit_preferences); edit_preferences->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_edit_preferences_activate)); - + // JumpTo + MenuItem* simulation_jump_to = NULL; + _refXml->get_widget("MenuItem.Simulation.JumpTo", simulation_jump_to); + simulation_jump_to->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_simulation_jump_to_activate)); // enable/disable show threads on widgets MenuItem* show_threads; diff --git a/src/gui_builder.hh b/src/gui_builder.hh index 68ac2a7..e5a5a31 100644 --- a/src/gui_builder.hh +++ b/src/gui_builder.hh @@ -56,6 +56,8 @@ namespace sgpem void on_edit_preferences_activate(); + void on_simulation_jump_to_activate(); + void on_view_show_threads_activate(); void on_view_show_holt_graph_activate(); diff --git a/src/jump_to_dialog.cc b/src/jump_to_dialog.cc new file mode 100644 index 0000000..15d855d --- /dev/null +++ b/src/jump_to_dialog.cc @@ -0,0 +1,95 @@ +// src/jump_to_dialog.cc - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#include "jump_to_dialog.hh" +#include +#include +#include +#include +#include + +#include +#include + +#include "gettext.h" + +#include + +using namespace sgpem; +using namespace Gtk; +using namespace Glib; +using Gnome::Glade::Xml; +using std::vector; + +JumpToDialog::JumpToDialog(BaseObjectType* cobject, const RefPtr& glade) : + Dialog(cobject), _glade(glade), _target_instant(0) +{ + _glade->get_widget("OK.Button", _ok_button); + _glade->get_widget("Jump.Button", _jump_button); + _glade->get_widget("Stop.Button", _stop_button); + _glade->get_widget("Instant.Spin", _instant_spin); + _glade->get_widget("ProgressBar", _progress); + + + /** ATTACH SIGNAL HANDLERS FOR BUTTONS **/ + + _jump_button->signal_clicked().connect( + sigc::mem_fun(*this, &JumpToDialog::_on_jump)); + + _stop_button->signal_clicked().connect( + sigc::mem_fun(*this, &JumpToDialog::_on_stop)); + + // FIXME: not implemented + _stop_button->set_sensitive(false); +} + +void +JumpToDialog::_on_jump() +{ + _ok_button->set_sensitive(false); +// _stop_button->set_sensitive(true); + _jump_button->set_sensitive(false); + _progress->set_fraction(0.0); + + _target_instant = _instant_spin->get_value_as_int(); + + Simulation::get_instance().attach(*this); + Simulation::get_instance().jump_to(_target_instant); + Simulation::get_instance().detach(*this); + + _ok_button->set_sensitive(true); +// _stop_button->set_sensitive(false); + _jump_button->set_sensitive(true); +} + +void +JumpToDialog::_on_stop() +{ +} + +void +JumpToDialog::update(const Simulation& changed_simulation) +{ + unsigned int front = changed_simulation.get_history().get_front(); + + double percent = static_cast(front) / _target_instant; + + _progress->set_fraction(percent); +} diff --git a/src/jump_to_dialog.hh b/src/jump_to_dialog.hh new file mode 100644 index 0000000..31166e5 --- /dev/null +++ b/src/jump_to_dialog.hh @@ -0,0 +1,61 @@ +// src/jump_to_dialog.hh - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef JUMP_TO_DIALOG_HH +#define JUMP_TO_DIALOG_HH 1 + +#include "config.h" + +#include + +#include +#include +#include +#include + +namespace sgpem +{ + class JumpToDialog : public Gtk::Dialog, public SimulationObserver + { + public: + JumpToDialog(BaseObjectType* cobject, const Glib::RefPtr& glade); + + private: + void _on_jump(); + void _on_stop(); + + void update(const Simulation& changed_simulation); + + Glib::RefPtr _glade; + + Gtk::Button* _jump_button; + Gtk::Button* _stop_button; + Gtk::Button* _ok_button; + Gtk::SpinButton* _instant_spin; + + Gtk::ProgressBar* _progress; + + unsigned int _target_instant; + }; + +} //~ namespace sgpem + + +#endif //~ JUMP_TO_DIALOG_HH