Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

DrawStats.hpp 7.5 KB
Newer Older
Mathieu Faverge's avatar
Mathieu Faverge committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
** 
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
** 
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
** 
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
31
** ViTE developers are (for version 0.* to 1.0):
Mathieu Faverge's avatar
Mathieu Faverge committed
32 33 34 35 36 37 38 39 40 41 42
**
**        - COULOMB Kevin
**        - FAVERGE Mathieu
**        - JAZEIX Johnny
**        - LAGRASSE Olivier
**        - MARCOUEILLE Jule
**        - NOISETTE Pascal
**        - REDONDY Arthur
**        - VUCHENER Clément 
**
*/
43 44 45 46 47 48 49 50
/*!
 *\file DrawStats.hpp
 */

#ifndef DRAW_STATS_HPP
#define DRAW_STATS_HPP

/*!
51 52
 * \def _HEIGHT_FOR_ONE_CONTAINER_DEFAULT
 * \brief The default height for one container's statistics.
53
 */
54
#define _HEIGHT_FOR_ONE_CONTAINER_DEFAULT 450.0f
55 56

/*!
57 58 59
 * \def _POS_X_CONTAINER_NAME
 * \brief The default x position for the container name.
 *        The origin is set at the north west.
60
 */
61
#define _POS_X_CONTAINER_NAME 10.0f
62

63 64 65 66 67
/*!
 * \def _POS_Y_CONTAINER_NAME
 * \brief The default y position for the container name.
 *        The origin is set at the north west.
 */
68
#define _POS_Y_CONTAINER_NAME _HEIGHT_FOR_ONE_CONTAINER_DEFAULT-50.0f
69 70 71 72 73 74 75 76 77 78 79

/*!
 * \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.
 */
80
#define _START_HISTOGRAM_X_DEFAULT 80.f
81 82 83 84 85

/*!
 * \def _START_HISTOGRAM_Y_DEFAULT
 * \brief The default Y position for origin in histogram mode.
 */
86
#define _START_HISTOGRAM_Y_DEFAULT _HEIGHT_FOR_ONE_CONTAINER_DEFAULT/2.
87

88 89 90 91 92 93 94 95 96 97 98
/*!
 * \def _POS_X_LEGEND_DEFAULT
 * \brief The default position for the legend.
 */
#define _POS_X_LEGEND_DEFAULT 10.f

/*!
 * \def _POS_Y_LEGEND_DEFAULT
 * \brief The default position for the legend.
 */
#define _POS_Y_LEGEND_DEFAULT 60.f
99 100 101 102 103 104 105 106 107 108 109


/*!
 * \class DrawStats
 * \brief Browse the stats and call back T drawing methods
 */
template<class T>
class DrawStats {
    
protected:
    
110 111 112
    /*!
     * \brief The containers which we want the statistics
     */
113
    std::vector<Container *> _containers_to_print;
114

115 116 117
    /*!
     * \brief The states and their statistics
     */
118 119
    std::vector<std::map<const EntityValue*, stats*> > _states;

120
    // Interval to compute statistics
121 122
    double _start_time;
    double _end_time;
123 124 125 126
    /*!
     * \brief unused for the moment.
     * Can be useful to keep the previous stats and so do not compute them one more time, if the interval [_prev_start, _prev_end] belongs to [_new_start, _new_end]
     */
127
    double _previous_start_time;
128 129 130
    /*!
     * \brief unused for the moment.
     */
131
    double _previous_end_time;
132

133 134 135 136
    // Geometrical informations about the stats shape.
    double _size_for_one_container;
    double _pos_x_container_name;
    double _pos_y_container_name;
137

138 139 140 141 142
    double _percentage_height_default;

    double _width_for_rect_legend;
    double _height_for_rect_legend;

143
    double _max_width;
144

145 146 147 148 149
public:
    /*
     * \brief The default constructor
     */
    DrawStats() {
150
        _size_for_one_container = _HEIGHT_FOR_ONE_CONTAINER_DEFAULT;
151
        set_geometrical_informations();
152 153 154 155 156 157 158 159 160 161 162
    }

    
    /*!
     * \brief The destructor
     */
    virtual ~DrawStats() {
    }


    /*!
163
     * \fn build(T* draw_object, std::vector<Container *> containers_to_print)
164 165
     * \brief The trace building function.
     * \param draw_object the kind of object which will be drawn (OpenGL, SVG...).
166
     * \param containers_to_print the container's data.
167
     */
168
    virtual void build(T* draw_object, std::vector<Container *> containers_to_print) = 0;
169

170 171 172 173 174
    /*!
     * \fn end_draw(T* draw_object)
     * \brief Set the end of the draw.
     * \param draw_object the kind of object which will be drawn (OpenGL, SVG...).
     */
175 176
    inline void end_draw(T* draw_object) {
        _previous_start_time = _start_time;
177
        _previous_end_time   = _end_time;
178 179 180
        draw_object->end_draw();
    }

181 182 183 184
    /*!
     * \fn set_times(const double start, const double end)
     * \brief Set the beginning and ending times of the draw.
     */
185
    inline void set_times(const double start, const double end) {
186
        _start_time = start;
187
        _end_time   = end;
188 189
    }

190
    /*! 
191 192 193
     * \fn get_max_percentage(std::map<const EntityValue*, stats*> &temp_states) const
     * \brief Get the biggest percentage of times for all the stats
     * \param temp_states The stats where we want to get the longest
194 195 196
     * \return a value between 0. and 1.
     *
     */
197
    virtual double get_max_percentage(std::map<const EntityValue*, stats*> &temp_states) const {
198 199
        double value;
        double max_length = 0.;
200
        for (std::map<const EntityValue *, stats *>::iterator it = temp_states.begin();
201 202 203 204 205 206 207 208 209
             it != temp_states.end();
             it ++) {
            if((*it).second->_total_length >= max_length) {
                max_length = (*it).second->_total_length;
            }
        }
        value = max_length/(_end_time-_start_time);

        //std::cerr << value << std::endl;
210
       return value;
211 212
    }

213 214 215 216 217
    /*! 
     * \fn updateGL(T* draw_object) const
     * \brief Update the render window(only for OpenGL render)
     * \param draw_object the kind of object which will be drawn (OpenGL, SVG...).
     */
218
    virtual void updateGL(T* draw_object) const {
219 220 221
        draw_object->updateGL();
    }

222 223 224 225
    /*! 
     * \fn set_geometrical_informations()
     * \brief Set some infos for the displaying
     */
226 227
    virtual void set_geometrical_informations() {
        _pos_x_container_name = _POS_X_CONTAINER_NAME;
228
        _pos_y_container_name = _POS_Y_CONTAINER_NAME;
229 230 231 232 233 234 235 236
        
        _percentage_height_default = (_size_for_one_container - _START_HISTOGRAM_Y_DEFAULT - 20) / 100.;
     
        /* Size for rectangles in the legend */
        _width_for_rect_legend = 20.;
        _height_for_rect_legend = 15.;
        _max_width = 0;
    }
237 238

    /*! 
239 240
     * \fn set_geometrical_informations_object(T* draw_object)
     * \brief Set the total width and height for one container for the draw object
241 242
     * \param draw_object The kind of object which will be drawn (OpenGL, SVG...).
     */
243
    virtual void set_geometrical_informations_object(T* draw_object) {
244
        draw_object->set_total_width(this->_max_width);
245
        draw_object->set_height_for_one_container(this->_size_for_one_container);
246
    }
247 248 249
};
    
#endif