- Implemented jumpto for the gui, it has some problems, but at 4:00 AM a human being should be doing something else, perhaps sleeping

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1034 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-09-07 02:08:00 +00:00
parent 0f718f2899
commit 4aa7bcf460
6 changed files with 825 additions and 439 deletions

View File

@ -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
# ############################################################

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,7 @@
#include "schedulables_tree_widget.hh"
#include "simulation_widget.hh"
#include "resources_widget.hh"
#include "jump_to_dialog.hh"
#include <sgpemv2/templates/sequences.tcc>
@ -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<Xml> 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;

View File

@ -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();

95
src/jump_to_dialog.cc Normal file
View File

@ -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 <sgpemv2/templates/sequences.tcc>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh>
#include <sgpemv2/simulation.hh>
#include <sgpemv2/resource.hh>
#include <iostream>
#include <sstream>
#include "gettext.h"
#include <cassert>
using namespace sgpem;
using namespace Gtk;
using namespace Glib;
using Gnome::Glade::Xml;
using std::vector;
JumpToDialog::JumpToDialog(BaseObjectType* cobject, const RefPtr<Xml>& 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<double>(front) / _target_instant;
_progress->set_fraction(percent);
}

61
src/jump_to_dialog.hh Normal file
View File

@ -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 <sgpemv2/simulation_observer.hh>
#include <gtkmm/dialog.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/progressbar.h>
#include <libglademm/xml.h>
namespace sgpem
{
class JumpToDialog : public Gtk::Dialog, public SimulationObserver
{
public:
JumpToDialog(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade);
private:
void _on_jump();
void _on_stop();
void update(const Simulation& changed_simulation);
Glib::RefPtr<Gnome::Glade::Xml> _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