sgpemv2/src/simulation_widget.hh

144 lines
3.4 KiB
C++
Raw Normal View History

// src/simulation_widget.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 SIMULATION_WIDGET_HH
#define SIMULATION_WIDGET_HH 1
#include "config.h"
#include "cairo_widget.hh"
#include "backend/history_observer.hh"
#include "backend/schedulable.hh"
#include "backend/simulation_observer.hh"
namespace sgpem
{
class SimulationWidget : public SimulationObserver, public HistoryObserver, public CairoWidget
{
public:
SimulationWidget(Simulation& simulation);
virtual ~SimulationWidget();
virtual void update(const Simulation& changed_simulation);
virtual void update(const History& changed_history);
bool get_show_threads();
bool set_show_threads(bool show);
protected:
//virtual bool on_button_press_event(GdkEventButton* event);
// void change_scaling_mode();
void draw_widget(cairo_t* ctx);
virtual void calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height);
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);
void make_gradients();
private:
Simulation* _simulation;
bool _show_threads;
/**
drawing x unit
*/
double _x_unit;
/**
drawing y unit
*/
double _y_unit;
/**
actual number of processes
*/
int _n_proc;
/**
actual number of threads
*/
int _n_thr;
/**
* 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;
cairo_pattern_t* _ready_process_gradient;
cairo_pattern_t* _running_process_gradient;
cairo_pattern_t* _blocked_process_gradient;
/**
* 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;
};
} //~ namespace sgpem
#endif //~ SIMULATION_WIDGET_HH