2006-08-12 17:49:37 +02:00
|
|
|
// src/simulation_widget.hh - Copyright 2005, 2006, University
|
2006-07-12 11:24:57 +02:00
|
|
|
// 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
|
|
|
|
|
2006-08-12 17:49:37 +02:00
|
|
|
#ifndef SIMULATION_WIDGET_HH
|
|
|
|
#define SIMULATION_WIDGET_HH 1
|
2006-07-12 11:24:57 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2006-08-04 22:08:55 +02:00
|
|
|
#include "cairo_widget.hh"
|
2006-09-07 02:43:00 +02:00
|
|
|
#include <sgpemv2/history_observer.hh>
|
|
|
|
#include <sgpemv2/schedulable.hh>
|
|
|
|
#include <sgpemv2/simulation_observer.hh>
|
2006-07-12 11:24:57 +02:00
|
|
|
|
|
|
|
namespace sgpem
|
|
|
|
{
|
2006-08-21 19:50:44 +02:00
|
|
|
class SimulationWidget : public SimulationObserver, public HistoryObserver, public CairoWidget
|
2006-07-12 11:24:57 +02:00
|
|
|
{
|
|
|
|
public:
|
2006-08-21 19:50:44 +02:00
|
|
|
SimulationWidget(Simulation& simulation);
|
2006-08-12 17:49:37 +02:00
|
|
|
virtual ~SimulationWidget();
|
2006-08-23 02:34:55 +02:00
|
|
|
|
|
|
|
virtual void update(const Simulation& changed_simulation);
|
|
|
|
virtual void update(const History& changed_history);
|
|
|
|
|
|
|
|
bool get_show_threads();
|
|
|
|
bool set_show_threads(bool show);
|
2006-07-12 11:24:57 +02:00
|
|
|
|
|
|
|
protected:
|
2006-08-20 05:49:17 +02:00
|
|
|
//virtual bool on_button_press_event(GdkEventButton* event);
|
|
|
|
// void change_scaling_mode();
|
2006-08-18 21:54:24 +02:00
|
|
|
|
2006-08-12 17:49:37 +02:00
|
|
|
void draw_widget(cairo_t* ctx);
|
2006-08-18 09:27:00 +02:00
|
|
|
|
2006-08-21 15:02:04 +02:00
|
|
|
virtual void calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height);
|
|
|
|
|
2006-08-23 02:34:55 +02:00
|
|
|
void count_elements();
|
|
|
|
void draw_names(cairo_t* ctx);
|
|
|
|
void draw_grid(cairo_t* ctx);
|
|
|
|
void draw_bars(cairo_t* ctx);
|
|
|
|
void draw_instant_rect(cairo_t* ctx, double x, double y,
|
|
|
|
double w, double h, sgpem::Schedulable::state state);
|
2006-09-04 16:23:42 +02:00
|
|
|
void make_gradients();
|
2006-08-23 02:34:55 +02:00
|
|
|
|
|
|
|
|
2006-08-18 09:27:00 +02:00
|
|
|
private:
|
2006-08-21 19:50:44 +02:00
|
|
|
Simulation* _simulation;
|
2006-08-23 02:34:55 +02:00
|
|
|
bool _show_threads;
|
2006-09-04 16:23:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
drawing x unit
|
|
|
|
*/
|
|
|
|
double _x_unit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
drawing y unit
|
|
|
|
*/
|
|
|
|
double _y_unit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
actual number of processes
|
|
|
|
*/
|
2006-08-23 02:34:55 +02:00
|
|
|
int _n_proc;
|
2006-09-04 16:23:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
actual number of threads
|
|
|
|
*/
|
2006-08-23 02:34:55 +02:00
|
|
|
int _n_thr;
|
|
|
|
|
2006-09-04 16:23:42 +02:00
|
|
|
|
2006-08-23 02:34:55 +02:00
|
|
|
/**
|
|
|
|
* top margin in y units
|
|
|
|
*/
|
|
|
|
double _yu_top_margin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* left margin in x units
|
|
|
|
*/
|
|
|
|
double _xu_left_margin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* left margin in x units
|
|
|
|
*/
|
|
|
|
double _xu_left_graph_margin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* bar spacing in y units
|
|
|
|
*/
|
|
|
|
double _yu_process_bar_spacing;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* process bar height in y units
|
|
|
|
*/
|
|
|
|
double _yu_process_bar_height;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* thread bar spacing in y units
|
|
|
|
*/
|
|
|
|
double _yu_thread_bar_spacing;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* thread bar height in y units
|
|
|
|
*/
|
|
|
|
double _yu_thread_bar_height;
|
|
|
|
|
2006-09-04 16:23:42 +02:00
|
|
|
cairo_pattern_t* _ready_process_gradient;
|
|
|
|
cairo_pattern_t* _running_process_gradient;
|
|
|
|
cairo_pattern_t* _blocked_process_gradient;
|
2006-09-06 01:49:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to redraw partially the widget.
|
|
|
|
* If the redraw come from Simulation update this flag is true
|
|
|
|
* and are redrawn only the last time tics.
|
|
|
|
* If the redraw is needed by History update or resize this flag is false.
|
|
|
|
*/
|
|
|
|
bool _partial_redraw;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Last time tic drawn.
|
|
|
|
*/
|
|
|
|
unsigned int _last_drawn;
|
2006-07-12 11:24:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} //~ namespace sgpem
|
|
|
|
|
|
|
|
|
2006-08-12 17:49:37 +02:00
|
|
|
#endif //~ SIMULATION_WIDGET_HH
|