Commit 83bfb929 authored by Pascal Noisette's avatar Pascal Noisette

commentaire de code : TODO verifier les elements au debut et a la fin lorsque...

commentaire de code : TODO verifier les elements au debut et a la fin lorsque l'interval est precise (bug causant des arrondi)
parent ca9344d2
......@@ -366,7 +366,9 @@ inline void Svg::start_draw(){
inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){
Element_pos xprime,yprime;
/*positions are translated to MARGINTOP : the upper region reserved for scale*/
/*heights are grown by _height_factor : conversion from time in ms to pixel*/
yprime = _height_factor*y + MARGINTOP;
xprime = _height_factor*x;
......@@ -401,7 +403,13 @@ inline void Svg::start_draw_counter(){
inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
/*computed position according to adjusted parameters*/
/*widths are widen by _wide_factor : conversion from time in ms to pixel*/
/*heights are grown by _height_factor : conversion from time in ms to pixel*/
/*positions are translated to _container_width_max : the left region occupied by containers*/
/*positions are translated to MARGINTOP : the upper region reserved for scale*/
/*whenever a time selection is set : positions are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/
Element_pos xprime = x*_wide_factor + _container_width_max ;
Element_pos yprime = y* _height_factor + MARGINTOP;
Element_pos switchvalue = _container_width_max;
......@@ -520,19 +528,20 @@ inline void Svg::start_draw_arrows(){
inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
/*selection*/
/*selection*/
/*may be outofrange*/
if (_end_interval_time)
if (start_time>_end_interval_time)
return;
if (end_time<_start_interval_time)
return;
/*line equation y = a*x+b */
/*arrow line equation y = a*x+b */
Element_pos a = ( 1.0*(end_height - start_height) )/(end_time - start_time);
Element_pos b = start_height - a*(start_time);
/*parameter to be adjusted to the time selection*/
Element_pos start_timeprime;
Element_pos end_timeprime;
Element_pos start_heightprime;
......@@ -540,7 +549,7 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_
bool trunc = false;
/*begining*/
/*begining : left adjustement*/
if (start_time<_start_interval_time)
{
start_timeprime = _start_interval_time ;
......@@ -549,40 +558,56 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_
else
{
start_timeprime = start_time ;
start_heightprime = start_height;//which stay a*starttimeprime+b
start_heightprime = start_height;
}
/*endding*/
/*endding as specified parameter*/
end_timeprime = end_time ;
end_heightprime = end_height;//except :
end_heightprime = end_height;
/*except if an _end_interval_time is set */
if (_end_interval_time)
{
if (end_time>_end_interval_time)
{
{
/*adjustement on the right and no spike !*/
trunc = true;
end_timeprime = _end_interval_time;
end_heightprime = a*end_timeprime+b;
}
}
/*update of the time*/
_total_time = max( _total_time,end_timeprime);
/*computed position according to adjusted parameters*/
/*width are widen by _wide_factor : conversion from time in ms to pixel*/
/*heights are grown by _height_factor : conversion from time in ms to pixel*/
/*positions are translated to _container_width_max : the left region occupied by containers*/
/*positions are translated to MARGINTOP : the upper region reserved for scale*/
/*whenever a time selection is set : state are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/
Element_pos x1=(start_timeprime )*_wide_factor + _container_width_max -_start_interval_time*_wide_factor ;
Element_pos y1=start_heightprime* _height_factor + MARGINTOP;
Element_pos x2=(end_timeprime)*_wide_factor+ _container_width_max -_start_interval_time*_wide_factor;
Element_pos y2=end_heightprime* _height_factor + MARGINTOP;
/*an arrow :*/
Svg::line("arrow",x1 ,y1 ,x2,y2);
if (!trunc)
Svg::triangle("arrow",x2 ,y2+ARROWSIZE,x2 ,y2-ARROWSIZE,x2+ARROWSIZE,y2);//spike
Svg::triangle("arrow",x2 ,y2+ARROWSIZE,x2 ,y2-ARROWSIZE,x2+ARROWSIZE,y2);
}
inline void Svg::end_draw_arrows(){
}
......@@ -590,6 +615,13 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
Element_pos xprime,yprime,wprime,hprime;
if (h<=0 || w<=0 || x<0 || y<0){
std::cerr<<"draw_container : specified argument isn't positive double"<<std::endl;
return;
}
/*parameters are grown : conversion from time in ms to pixel*/
/*positions are translated to MARGINTOP : the upper region reserved for scale*/
wprime = _height_factor*w;
hprime = _height_factor*h;
yprime = _height_factor*y + MARGINTOP;
......@@ -599,6 +631,7 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
Svg::rectangle("container",wprime, hprime, xprime, yprime, 0xbb, 0xbb, 0xbb);
_container_width_max = max(wprime+xprime+ MARGIN,_container_width_max);
_container_height_min = min(hprime,_container_height_min);
}
......@@ -617,9 +650,15 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
Element_pos startprime;
Element_pos endprime;
if (start<=0 || end <=0 || height<0 || level<0){
std::cerr<<"draw_state : specified argument isn't positive double"<<std::endl;
return;
}
/*selection*/
/*may be outofrange*/
/*an outofrange state will not be displayed*/
if (_end_interval_time)
if (start>_end_interval_time)
return;
......@@ -627,13 +666,14 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
if (end<_start_interval_time)
return;
/*begining*/
/*a state may be shortenend on its left*/
if (start<_start_interval_time)
startprime = _start_interval_time ;
else
startprime = start ;
/*endding*/
endprime = end; //except :
/*or on its end*/
endprime = end;
if (_end_interval_time)
{
if (end>_end_interval_time)
......@@ -643,14 +683,24 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
_total_time = max( _total_time,endprime);
/*adjusted parameter to positions*/
/*states are widen by _wide_factor : conversion from time in ms to pixel*/
/*states are grown by _height_factor : conversion from time in ms to pixel*/
/*states are translated to _container_width_max : the left region occupied by containers*/
/*states are translated to MARGINSTATE : the margin between two container*/
/*states are translated to MARGINTOP : the upper region reserved for scale*/
/*states height is not the specified parameter : container_height_min replaces height which enable the state to have an uniform size */
/*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/
w = endprime*_wide_factor-startprime*_wide_factor;
h = _container_height_min;
x = (startprime )*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor;
y = level* _height_factor + MARGINTOP;
if(w<_epsilon){
return;
return;
}
......@@ -664,16 +714,24 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
*/
inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
/*selection*/
if (time<_start_interval_time)
return;
if (_end_interval_time){
if (time>_end_interval_time)
return;
if (time<=0 || height <=0 || container_height <=0){
std::cerr<<"draw_event : specified argument isn't positive double"<<std::endl;
return;
}
std::cerr<<"draw_event : is called not yet implemented"<<std::endl;
/*an outofrange event will not be displayed*/
if (_end_interval_time)
if (time>_end_interval_time)
return;
if (time<_start_interval_time)
return;
_total_time = max( _total_time,time);
Svg::rectangle("event",MARGIN,container_height, time + _container_width_max -_start_interval_time*_wide_factor, height + MARGINTOP, 0x17, 0x60, 0xe7);
Svg::rectangle("event",MARGIN,_container_height_min, time + _container_width_max -_start_interval_time*_wide_factor, height + MARGINTOP, 0x17, 0x60, 0xe7);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment