Commit 1e7275d2 authored by Augustin Degomme's avatar Augustin Degomme
Browse files

- double clicking on a variable now displays the value of the variable at the pointed time

- slight correction for drag and dropping of containers
parent 3fec3731
......@@ -1060,10 +1060,17 @@ void Core::launch_action(int state, void* arg) {
Element_pos xr = ((Element_pos*)arg)[2] * (_trace->get_depth()+1);
if(xr<0)return;
for(int i=0; i < (_trace->get_depth() - xr); i++){
Element_pos xr2 = ((Element_pos*)arg)[3] * (_trace->get_depth()+1);
if(xr2<0)return;
for(int i=0; i < (const_cast<Container*>(container)->get_depth() - xr); i++){
container= container->get_parent();
}
for(int i=0; i < (const_cast<Container*>(container2)->get_depth() - xr2); i++){
container2=container2->get_parent();
}
//we cannot switch when containers' parents are not the same
if((container->get_parent()!=container2->get_parent()))return;
......
......@@ -353,15 +353,15 @@ void Hook_event::mouseReleaseEvent(QMouseEvent * event){
event->accept();/* accept the event */
}else if (_mouse_pressed_inside_container){
Element_pos y1 = render_to_trace_y(screen_to_render_y(_mouse_y));
Element_pos x1 = screen_to_render_x(_new_mouse_x) / (_x_scale_container_state*Info::Render::width);
Element_pos y2 = render_to_trace_y(screen_to_render_y(_new_mouse_y));
Element_pos buf[3]={y1,y2, x1};
Element_pos y1 = render_to_trace_y(screen_to_render_y(_mouse_y));
Element_pos x1 = screen_to_render_x(_new_mouse_x) / (_x_scale_container_state*Info::Render::width);
Element_pos y2 = render_to_trace_y(screen_to_render_y(_new_mouse_y));
Element_pos x2 = screen_to_render_x(_new_mouse_x) / (_x_scale_container_state*Info::Render::width);
Element_pos buf[4]={y1,y2, x1, x2};
_core->launch_action(_core->_STATE_SWITCH_CONTAINERS, &buf);
_core->launch_action(_core->_STATE_SWITCH_CONTAINERS, &buf);
_mouse_pressed=false;
_mouse_pressed_inside_container=false;
_mouse_pressed=false;
_mouse_pressed_inside_container=false;
}else{
if (_new_mouse_x < _mouse_x){
......
......@@ -695,6 +695,7 @@ public:
*Message::get_instance() << "<center><strong>Variable</strong></center>"
<< "<strong>Container:</strong> " << variable->get_container()->get_name().to_string() << "<br />"
<< "<strong>Type:</strong> " << variable->get_type()->get_name().to_string() << "<br />"
<< "<strong>Value:</strong> " << variable->get_value_at(x) << "<br />"
<< "<strong>Min:</strong> " << variable->get_min().get_value() << "<br />"
<< "<strong>Max:</strong> " << variable->get_max().get_value() << "<br />";
print_extra_fields("Type", variable->get_type()->get_extra_fields());
......
......@@ -42,6 +42,9 @@
*/
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <map>
#include <list>
#include <vector>
......@@ -80,6 +83,22 @@ const list<pair<Date, Double> > *Variable::get_values() const {
return &_values;
}
const double Variable::get_value_at(double d) const {
list<pair<Date, Double> >::const_iterator it= _values.begin();
const list<pair<Date, Double> >::const_iterator it_end= _values.end();
if(it==it_end)return 0.0;
const Date* previous=&((*it).first);
const Double * val = &((*it).second);
it++;
while ((it!=it_end)){
if(((*it).first.get_value())>d)break;
previous=&((*it).first);
val = &((*it).second);
it++;
}
return val->get_value();
}
Double Variable::get_min() const {
return _min;
}
......
......@@ -89,6 +89,10 @@ public:
* \brief Get the values of the variable
*/
const std::list<std::pair<Date, Double> > *get_values() const;
/*!
* \brief Get the value at a given time
*/
const double get_value_at(double d) const ;
/*!
* \brief Get the minimum of the values
......
Supports Markdown
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