Commit 296919ef authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Continuation of the statistics.

The histogram works for one container printed (else there are overlaps).
Adjustments for the size and disposition will be done later.
parent 370c0835
####
#
# /*!
# * \brief Makefile for the ViTE interface. Commands are : \
# * make all : compiles the released version.
# * make debugs : compiles with debug informations.
# * make mtest : compiles the tests.
# * make clean : deletes generated files.
# */
#
###
all:
cd ./src && qmake-qt4 && make all
@echo " "
@echo "Compilation completed! (release)"
@echo " "
doc:
doxygen Doxyfile
@echo " "
@echo "Documentation generated successfully !"
@echo "Please open index.html in 'html' folder for a web documentation, or use 'make' in the 'latex' folder for a pdf documentation."
@echo " "
#build:
# cd ./src && qmake-qt4 -project "TARGET += vite" "RESOURCES= vite.qrc" "SOURCES+=../../main.cpp" "OBJECTS_DIR=../bin" "DESTDIR=../../bin" "CONFIG+=uitools" "QT+=opengl" && qmake-qt4 -makefile -o Makefile src.pro && make all
# @echo " "
# @echo "Built and compiled! (release)"
# @echo " "
plugins:
cd ./plugin && qmake-qt4 && make
@echo " "
@echo "Plugins are built and installed ! Please manually install it ('libplugin.so') from 'plugin' folder to the qtdesigner plugin folder ('/usr/lib/qt4/plugins/designer' on linux) (plugin)"
@echo " "
#debugs:
#cd ./src && qmake-qt4 -project && qmake-qt4 -makefile -o Makefile "RESOURCES= vite.qrc" "OBJECTS_DIR=../debug" "CONFIG+=uitools debug console" "QT+=opengl" "DESTDIR = ../debug" src.pro && make all
#mv src/*.o bin/
#@echo " "
#@echo "Compilation completed! (debug)"
#@echo " "
mtest:
make -C test
@echo " "
@echo "Compilation completed! (test)"
@echo " "
clean:
make -i -f Makefile wash # The washing is launched to ignore errors.
@echo " "
@echo "Cleaned!"
@echo " "
# Must be called with option -i, otherwise an error occured in the first instructions, the followings won't be executed.
wash:
cd ./src && $(RM) *~ *.o Makefile qrc_vite.cpp core
cd ./test && $(RM) *~ *.o Makefile core
cd ./bin && $(RM) *.o
cd ./debug && $(RM) *
......@@ -458,7 +458,8 @@ void Interface_graphic::on_close_triggered(){
_ui_info_trace_text->clear();/* Clear the current text (if exists) */
_ui_info_selection_text->clear();/* Clear the current text (if exists) */
_ui_info_window->hide();/* Hide the informative window */
//_stats_window->hide(); // Hide the stats window
//_stats_window->close_window();
_core->launch_action(Interface_console::_STATE_RELEASE_RENDER_AREA);
......
......@@ -24,7 +24,7 @@
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QTreeWidget" name="_nodes_selected">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
......@@ -80,12 +80,12 @@
<widget class="QComboBox" name="_kind_of_diagram_box">
<item>
<property name="text">
<string>Chart</string>
<string>Horizontal percentage</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal percentage</string>
<string>Chart</string>
</property>
</item>
</widget>
......@@ -99,7 +99,7 @@
</item>
</layout>
</item>
<item row="1" column="1">
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
......@@ -120,7 +120,7 @@
</item>
</layout>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer">
......@@ -159,7 +159,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
......@@ -243,15 +243,15 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Selected node :</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Selected node :</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -18,16 +18,11 @@ Render_stats_opengl::~Render_stats_opengl(){
}
void Render_stats_opengl::initializeGL(){
makeCurrent();
glClearColor(1.0, 0.5, 0.55, 1.0);
glEnable(GL_DEPTH_TEST);
doneCurrent();
}
void Render_stats_opengl::resizeGL(int width, int height){
makeCurrent();
glViewport(0, 0, width, height);
/* update informations about widget size */
......@@ -41,34 +36,57 @@ void Render_stats_opengl::resizeGL(int width, int height){
glMatrixMode(GL_MODELVIEW);
//cout << "resize: (" << width<<", "<<height<<")"<< endl;
doneCurrent();
}
void Render_stats_opengl::paintGL(){
makeCurrent();
// resizeGL(width(), height());
glClearDepth(1.0);
glClearColor(1.f, 1.f, 1.f, 1.0f);
// glClearColor(0.5f, 0.5f, 0.55f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0, _screen_width, 0, _screen_height);
glPushMatrix();
glTranslated(0, 10, 0);
glBegin(GL_QUADS);
{
glColor3ub(255, 123, 0);
glVertex2d(0, 10);
glVertex2d(125, 10);
glVertex2d(125, 25);
glVertex2d(0, 25);
}
glEnd();
glPopMatrix();
doneCurrent();
list<Element_pos>::iterator it_pos;
list<string>::iterator it_txt;
Element_pos buf_x;
Element_pos buf_y;
string buf_txt;
glCallList(_rect_list);
/* Draw container texts */
for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end() ; it_txt ++, it_pos ++) {
buf_x = *it_pos;
it_pos ++;
buf_y = *it_pos;
buf_txt = *it_txt;
glPushMatrix();
glColor3d(0, 0, 0);
glRasterPos2f(buf_x, buf_y);
const unsigned int buf_text_size = buf_txt.length();
for(unsigned int i = 0 ; i < buf_text_size ; i ++){
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.c_str()[i]);
}
glPopMatrix();
}/* end for(...) */
glFlush();
}
void Render_stats_opengl::set_total_height(Element_pos h) {
_render_height = h;
cout << "total height of the stats: " << h << endl;
//cout << "total height of the stats: " << h << endl;
}
......@@ -21,6 +21,19 @@ class Render_stats_opengl;
class Render_stats_opengl : public QGLWidget, public Render_stats {
Q_OBJECT
private:
/*!
* \brief Contains container text coordinates.
*/
std::list<Element_pos> _text_pos;
/*!
* \brief Contains container strings.
*/
std::list<std::string> _text_value;
GLuint _rect_list;
public:
/*!
......@@ -65,7 +78,14 @@ public:
void draw_text(const Element_pos x, const Element_pos y, const std::string value);
/*!
* \brief Draw the text of a container.
* \brief Draw a line.
* \param x the x position of the text.
* \param y the y position of the text.
* \param value the string value of the text.
*/
void draw_axis(const Element_pos x, const Element_pos y, const Element_pos size_x, const Element_pos size_y);
/*!
* \brief Draw a rectangle.
* \param x the x position of the text.
* \param y the y position of the text.
* \param value the string value of the text.
......@@ -84,16 +104,52 @@ public:
};
inline void Render_stats_opengl::start_draw(){}
inline void Render_stats_opengl::start_draw(){
_text_pos.clear();
_text_value.clear();
makeCurrent();
_rect_list = glGenLists(10);
glNewList(_rect_list, GL_COMPILE);
}
inline void Render_stats_opengl::draw_text(const Element_pos x, const Element_pos y, const std::string value) {
std::cout << "text: " << value << " @ position : ("<<x<<","<<y<<")." << std::endl;
_text_pos.push_back(x);
_text_pos.push_back(y);
_text_value.push_back(value);
// std::cout << "text: " << value << " @ position : ("<<x<<","<<y<<")." << std::endl;
}
inline void Render_stats_opengl::draw_axis(const Element_pos x, const Element_pos y, const Element_pos size_x, const Element_pos size_y){
glBegin(GL_LINES);
{
glColor3ub(0, 0, 0);
glVertex2i(x, y);
glVertex2i(x+size_x, y);
glVertex2i(x, y);
glVertex2i(x, y+size_y);
}
glEnd();
}
inline void Render_stats_opengl::draw_rect(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h, const Element_pos r, const Element_pos g, const Element_pos b) {
std::cout << "rect: " << "x "<<x<<", y"<<y<<", w"<<w<<", "<<h << " ("<<r<<", "<<g<<", "<<b<<std::endl;
glBegin(GL_QUADS);
{
glColor3d(r, g, b); glVertex2d(x, y);
glColor3d(r, g, b); glVertex2d(x, y+h);
glColor3d(r, g, b); glVertex2d(x+w, y+h);
glColor3d(r, g, b); glVertex2d(x+w, y);
}
glEnd();
//std::cout << "rect: " << "x ="<<x<<", y = "<<y<<", w = "<<w<<", "<<h << " ("<<r<<", "<<g<<", "<<b<<") "<<std::endl;
}
inline void Render_stats_opengl::end_draw(){}
inline void Render_stats_opengl::end_draw(){
glEndList();
paintGL();
doneCurrent();
}
#endif
......@@ -17,13 +17,44 @@
* \def _HEIGHT_FOR_ONE_CONTAINER_DEFAULT
* \brief The default height for one container's statistics.
*/
#define _HEIGHT_FOR_ONE_CONTAINER_DEFAULT 1.2f
#define _HEIGHT_FOR_ONE_CONTAINER_DEFAULT 300.0f
/*!
* \def _HEIGHT_V_SPACE_DEFAULT
* \brief The default vertical space between two statistics.
* \def _POS_X_CONTAINER_NAME
* \brief The default x position for the container name.
* The origin is set at the north west.
*/
#define _HEIGHT_V_SPACE_DEFAULT 0.2f
#define _POS_X_CONTAINER_NAME 10.0f
/*!
* \def _POS_Y_CONTAINER_NAME
* \brief The default y position for the container name.
* The origin is set at the north west.
*/
#define _POS_Y_CONTAINER_NAME _HEIGHT_FOR_ONE_CONTAINER_DEFAULT-10.0f
/*!
* \def _WIDTH_HISTOGRAM_DEFAULT
* \brief The default width for a container in histogram mode.
*/
#define _WIDTH_HISTOGRAM_DEFAULT 30.f
/*!
* \def _START_HISTOGRAM_X_DEFAULT
* \brief The default x position for origin in histogram mode.
*/
#define _START_HISTOGRAM_X_DEFAULT 100.f
/*!
* \def _START_HISTOGRAM_Y_DEFAULT
* \brief The default Y position for origin in histogram mode.
*/
#define _START_HISTOGRAM_Y_DEFAULT 100.f
/*!
* \def _PERCENTAGE_HEIGHT_DEFAULT
* \brief The default height for 1% in histogram mode.
*/
#define _PERCENTAGE_HEIGHT_DEFAULT 5.f
/*!
......@@ -39,14 +70,24 @@ protected:
std::vector<std::map<const EntityValue*, stats*> > _states;
// Geometrical informations about the stats shape.
double _start_time;
double _previous_start_time;
double _end_time;
double _previous_end_time;
// Geometrical informations about the stats shape.
double _size_for_one_container;
double _pos_x_container_name;
double _pos_y_container_name;
public:
/*
* \brief The default constructor
*/
DrawStats() {
_size_for_one_container = _HEIGHT_FOR_ONE_CONTAINER_DEFAULT;
_pos_x_container_name = _POS_X_CONTAINER_NAME;
_pos_y_container_name = _POS_Y_CONTAINER_NAME;
}
......@@ -77,38 +118,102 @@ public:
draw_legend(draw_object, i);
}
draw_object->end_draw();
end_draw(draw_object);
}
void draw_container_name(T* draw_object, const int container_id){
void draw_container_name(T* draw_object, const int container_id) {
// Get the position for the i-th container name
// TO DO
Element_pos pos_x = 33;
Element_pos pos_y = 33 * container_id;
Element_pos pos_x = _pos_x_container_name;
Element_pos pos_y = _pos_y_container_name + _size_for_one_container * container_id;
std::string name = _containers_to_print[container_id]->get_name().to_string();
////
draw_object->draw_text(pos_x, pos_y, name);
}
void draw_diagram(T* draw_object, const int container_id, std::string kind_of_diagram){
// TO DO
draw_object->draw_text(0, container_id, kind_of_diagram);
void draw_diagram(T* draw_object, const int container_id, std::string kind_of_diagram) {
Statistic *stat_temp = new Statistic();
_containers_to_print[container_id]->fill_stat(stat_temp, Interval(_start_time, _end_time));
std::map<const EntityValue*, stats*> temp_states = stat_temp->get_states();
_states.push_back(temp_states);
// Printing of the trace
// Depending on the kind of diagram...
if(kind_of_diagram == "Horizontal percentage") {
int pos_x = _START_HISTOGRAM_X_DEFAULT;
int pos_y = _START_HISTOGRAM_Y_DEFAULT;
// Draw axes
draw_object->draw_axis(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT*(_states[container_id].size()+1), _PERCENTAGE_HEIGHT_DEFAULT*101);
draw_object->draw_text(pos_x-20, pos_y+_PERCENTAGE_HEIGHT_DEFAULT*101, "1");
// Draw the stats
for (map<const EntityValue *, stats *>::iterator it = temp_states.begin();
it != temp_states.end();
it ++) {
std::string name = (*it).first->get_name().to_string();
const Color *color = (const Color *)(*it).first->get_extra_fields()->find(std::string("Color"))->second;
std::cout << "State : " << name << " for " << (*it).second->_total_length*100./(_end_time-_start_time)<< "%" << std::endl;
// We have to convert the percentage in a rectangle and print it.
//draw_object->draw_text(pos_x, pos_y, name);
int height = (*it).second->_total_length*100.*_PERCENTAGE_HEIGHT_DEFAULT/(_end_time-_start_time);
draw_object->draw_rect(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT, height, color->get_red(), color->get_green(), color->get_blue());
pos_x += _WIDTH_HISTOGRAM_DEFAULT;
}
}
else {
*Message::get_instance() << kind_of_diagram << " not yet implemented" << Message::endw;
}
delete stat_temp;
}
void draw_legend(T* draw_object, const int container_id){
void draw_legend(T* draw_object, const int container_id) {
// TO DO
Element_pos pos_x = 33;
Element_pos pos_y = 33 * container_id;
std::string name = _containers_to_print[container_id]->get_name().to_string();
float red = 0.0f, green = 0.0f, blue = 0.0f;
Element_pos pos_x = _POS_X_CONTAINER_NAME;
Element_pos pos_y = 33 * (container_id+1);
int w = 30, h = 20;
/////
draw_object->draw_text(pos_x, pos_y, name);
draw_object->draw_rect(pos_x, pos_y, w, h, red, green, blue);
for (map<const EntityValue *, stats *>::iterator it = _states[container_id].begin();
it != _states[container_id].end();
it ++) {
std::string name = (*it).first->get_name().to_string();
draw_object->draw_text(pos_x, pos_y, name);
if((*it).first->get_extra_fields()->find(std::string("Color")) != (*it).first->get_extra_fields()->end()) {
const Color *color = (const Color *)(*it).first->get_extra_fields()->find(std::string("Color"))->second;
draw_object->draw_rect(pos_x-(w+10), pos_y, w, h, color->get_red(), color->get_green(), color->get_blue());
}
else{
draw_object->draw_rect(pos_x-(w+10), pos_y, w, h, 0., 0., 0.);
}
pos_x += 100;
}
}
inline void end_draw(T* draw_object) {
_previous_start_time = _start_time;
_previous_end_time = _end_time;
draw_object->end_draw();
}
inline void set_times(const double start, const double end){
_start_time = start;
_end_time = end;
}
void updateGL(T* draw_object){
draw_object->updateGL();
}
};
#endif
......@@ -116,33 +116,17 @@ void Stats_window::on_reload_button_clicked() {
}
DrawStats<Render_stats_opengl> drawer;
drawer.set_times(_start_time, _end_time);
drawer.build(_ui_stats_area, _selected_containers, _kind_of_diagram_box->currentText ().toStdString());
_previous_end_time = _end_time;
_previous_start_time = _start_time;
drawer.updateGL(_ui_stats_area);
}
// -> A mettre dans le template !
// void Stats_window::start_draw() {
// Statistic *stat_temp = new Statistic();
// Container *temp = _trace->search_container(String(_selected_containers[i]->get_name().to_string()));
// temp->fill_stat(stat_temp, Interval(_start_time, _end_time));
// // Bug des que c'est un noeud ^^
// cout << "number of events: " << stat_temp->get_nb_event() << endl;
// map<const EntityValue*, stats*> temp_map = stat_temp->get_states();
// for (map<const EntityValue *, stats *>::iterator it = temp_map.begin();
// it != temp_map.end();
// it ++) {
// cout << "State: " << (*it).first->get_name().to_string() << " for " << (*it).second->_total_length << " seconds." << endl;
// }
// delete stat_temp;
// }
// }
void Stats_window::close_window(){
_ui_stats_area->doneCurrent();
hide();
}
......@@ -57,7 +57,12 @@ public:
void set_container_names();
void set_trace(Trace *trace);
void init_window();
// void start_draw();
/*!
\fn close_window()
\brief Properly close the window
*/
void close_window();
private:
void set_container_names_rec(QTreeWidgetItem *current_node, Container *current_container);
......
#############################################################################
# Makefile for building: test_area
# Generated by qmake (2.01a) (Qt 4.4.0) on: dim. mars 22 16:53:28 2009
# Generated by qmake (2.01a) (Qt 4.4.0) on: sam. mai 2 20:54:48 2009
# Project: interface.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile interface.pro
# Command: /usr/bin/qmake -unix CONFIG+=debug_and_release -o Makefile interface.pro
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DTEST_SVG_MODE -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES)
CXXFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtUiTools -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4/QtXml -I/usr/include/qt4/QtXml -I/usr/include/qt4 -I. -I/usr/X11R6/include -I. -I.
LINK = g++
LFLAGS = -Wl,--no-undefined
LIBS = $(SUBLIBS) -L/usr/lib -L/usr/X11R6/lib -lglut -lGLEW -lQtXml -lQtOpenGL -lQtGui -lQtCore -lQtUiTools -lGLU -lGL -lpthread
AR = ar cqs
RANLIB =
first: debug
install: debug-install
uninstall: debug-uninstall
MAKEFILE = Makefile
QMAKE = /usr/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
COPY = cp -f