Commit 128a8939 authored by Pascal Noisette's avatar Pascal Noisette

option tiret interval start end pour selectionner un interval de temps et...

option tiret interval start end pour selectionner un interval de temps et tiret wide pour agrandir le tout, rend l'export utilisable
parent 77df97ad
......@@ -180,7 +180,7 @@ int Interface_console::get_state(int argc, char** argv){
Svg::set_wide_factor (100);
Svg::set_interval(0,0);
Svg::set_accuracy(0.1);
Svg::set_scale_frequency(50);
//Error::set_priority_min_printable(Error::_EVERYTHING);
if(argc == 1){
......@@ -250,31 +250,32 @@ int Interface_console::get_state(int argc, char** argv){
}
}
}
// else if((string)argv[i] == "-interval"){
else if((string)argv[i] == "-interval"){
// if (!(i +2 < argc)) {
// cerr << "interval argc" << endl;
// return _STATE_UNKNOWN;
// }
// if (argv[i+1][0] == '-') {
// cerr << "interval -" << endl;
// return _STATE_UNKNOWN;
// }
// if (!(argv[i+2][0] != '-')) {
// cerr << "interval -" << endl;
// return _STATE_UNKNOWN;
// }
if (!(i +2 < argc)) {
cerr << "interval argc" << endl;
return _STATE_UNKNOWN;
}
if (argv[i+1][0] == '-') {
cerr << "interval -" << endl;
return _STATE_UNKNOWN;
}
if (!(argv[i+2][0] != '-')) {
cerr << "interval -" << endl;
return _STATE_UNKNOWN;
}
// double t1 = atof(argv[i+1]);
// double t2 = atof(argv[i+2]);
double t1 = atof(argv[i+1]);
double t2 = atof(argv[i+2]);
// if (t1 >= t2) {
// cerr << "interval neg" << endl;
// return _STATE_UNKNOWN;
// }
// Svg::set_interval(t1,t2);
//}
if (t1 >= t2) {
cerr << "interval neg" << endl;
return _STATE_UNKNOWN;
}
Svg::set_interval(t1,t2);
i+=2;
}
else if((string)argv[i] == "-wide") {
if (i + 1 >= argc) {
cerr << "wide argc" << endl;
......@@ -285,6 +286,7 @@ int Interface_console::get_state(int argc, char** argv){
return _STATE_UNKNOWN;
}
Svg::set_wide_factor(atof(argv[i+1]));
i++;
}
else if((string)argv[i] == "-grow"){
......@@ -298,8 +300,21 @@ int Interface_console::get_state(int argc, char** argv){
}
Svg::set_height_factor(atof(argv[i+1]));
i++;
}
else if((string)argv[i] == "-scale"){
if (!(i + 1 < argc)) {
cerr << "scale argc" << endl;
return _STATE_UNKNOWN;
}
if (argv[i+1][0] == '-') {
cerr << "scale -" << endl;
return _STATE_UNKNOWN;
}
Svg::set_scale_frequency(atof(argv[i+1]));
i++;
}
else {
cerr << "the argument "<< argv[i] << " is unknown." << endl;
return _STATE_DISPLAY_HELP;
......
......@@ -13,7 +13,7 @@ void Svg::init(const char *path){
std::cerr<< "interval : [";
std::cerr<< _start_interval_time;
if ( _end_interval_time==0)
std::cerr<<"+oo" << endl;
std::cerr<<"+oo[" << endl;
else
std::cerr<<_end_interval_time << endl;
......@@ -137,28 +137,55 @@ void Svg::end(){
void Svg::display_time_scale()
{
_total_width = _total_time;
Element_pos w = _total_width*_wide_factor;
Element_pos h = MARGINTOP;
Element_pos x = _container_width_max + MARGINSTATE;
Element_pos h = (MARGINTOP*1.0)/2;
Element_pos x = _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor;
Element_pos y = 0;
Element_col r = 0;
Element_col g = 0;
Element_col b = 0;
Element_col r = 255;
Element_col g = 255;
Element_col b = 255;
_time_scale << "\n<rect class='scale' title='scale'"
<<"' width='" << w
<<"' height='"<< h
<<"' x='" << x
<<"' y='" << y
<<"' fill='rgb("<<r<<","<<g<<","<<b
<<")'/>";
<<" width='" << w
<<"' height='"<< h
<<"' x='" << x
<<"' y='" << y
<<"' fill='rgb("<<r<<","<<g<<","<<b
<<")' stroke='black'"
<< " stroke-width='0.1'"
<< " />";
if (_end_interval_time)
_total_width = _total_time = min(_end_interval_time,_total_time);
Element_pos inc;
inc = (_scale_frequency) / (_wide_factor);
for(Element_pos i=_start_interval_time;i<_total_time;i+=inc){
x = (i)*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor;
_time_scale << "<text x='" << x <<"' y='" << y + h << "'>|";
_time_scale << i;
_time_scale << "</text>";
}
_svg_file.write(_time_scale.str().c_str(), _time_scale.str().size());
_time_scale.flush();
_time_scale.str("");
}
void Svg::set_height_factor (Element_pos w){
......@@ -179,6 +206,9 @@ _end_interval_time = t2;
}
void Svg::set_scale_frequency(Element_pos w){
_scale_frequency = w;
}
......
......@@ -87,6 +87,12 @@ It corresponds to the height of a containers in pixel
static double _epsilon;
/*!
* \brief the scale can be more accurate by increasing the _scale_frequency
*/
static double _scale_frequency;
/*!
......@@ -199,6 +205,12 @@ public:
*/
static void set_height_factor (Element_pos w);
/*!
* \brief the scale can be more accurate by increasing the _scale_frequency
*/
static void set_scale_frequency(Element_pos w);
/*Statistics : not yet implemented*/
......@@ -390,17 +402,18 @@ inline void Svg::start_draw_counter(){
inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
Element_pos xprime = x*_wide_factor + _container_width_max ;
Element_pos xprime = x*_wide_factor + _container_width_max ;
Element_pos yprime = y* _height_factor + MARGINTOP;
Element_pos switchvalue = _container_width_max;
if (_chronogramme_state==INIT)
{
if (xprime==switchvalue)
{
_chronogramme << "\n<path d='M"<< xprime << " " << yprime;
_chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor << " " << yprime;
_chronogramme_state=WAIT_FOR_POINT;
}
else
......@@ -421,7 +434,15 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
}
else
{
if (_end_interval_time)
if (x>_end_interval_time)
return;
if (x<_start_interval_time)
return;
_total_time = max( _total_time,x);
_chronogramme << " L" << xprime << " " << yprime;
}
......@@ -431,7 +452,7 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
{
if (xprime==switchvalue)
{
_chronogramme << "\n<path d='M"<< xprime << " " << yprime;
_chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor<< " " << yprime;
_chronogramme_state=WAIT_FOR_POINT;
}
else
......@@ -545,11 +566,12 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_
}
_total_time = max( _total_time,end_timeprime);
Element_pos x1=(start_timeprime )*_wide_factor + _container_width_max ;
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;
Element_pos x2=(end_timeprime)*_wide_factor+ _container_width_max -_start_interval_time*_wide_factor;
Element_pos y2=end_heightprime* _height_factor + MARGINTOP;
......@@ -618,10 +640,12 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
endprime = _end_interval_time;
}
_total_time = max( _total_time,endprime);
w = endprime*_wide_factor-startprime*_wide_factor;
h = _container_height_min;
x = (startprime )*_wide_factor + _container_width_max + MARGINSTATE;
x = (startprime )*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor;
y = level* _height_factor + MARGINTOP;
if(w<_epsilon){
......@@ -648,8 +672,8 @@ inline void Svg::draw_event(const Element_pos time, const Element_pos height, c
return;
}
Svg::rectangle("event",MARGIN,container_height, time + _container_width_max , height + MARGINTOP, 0x17, 0x60, 0xe7);
_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);
}
......
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