X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/5885f9816965f487fd852a9ea46bbc580c48d317..8b3ce9d2a3be2d9f8d23ba8602dffc50e30ab2c8:/Model/src/plantitem.cpp?ds=inline diff --git a/Model/src/plantitem.cpp b/Model/src/plantitem.cpp index aa3aa23..34360b0 100644 --- a/Model/src/plantitem.cpp +++ b/Model/src/plantitem.cpp @@ -1,6 +1,6 @@ - #include "plantitem.h" +#include using namespace PlaQui::Model; @@ -8,6 +8,8 @@ PlantItem::PlantItem(const std::string &_name):IConector(0, 0) { name = _name; updated = false; + fluid_color = RGB(255,255,255); + color_updated = false; } PlantItem::PlantItem(unsigned ins, unsigned outs):IConector(ins, outs) @@ -22,12 +24,48 @@ PlantItem::~PlantItem() void PlantItem::recieve_msg(int msg, IConector *who, void *data) { switch (msg) { - case MSG_QUERY_MAX_FLOW: + case MSG_QUERY_MAX_FLOW_OUT: // TODO return; break; + case MSG_QUERY_COLOR: + if (color_updated) { + who->recieve_msg(MSG_RESPONSE_COLOR, this, &fluid_color); + return; + } + update_color(); + who->recieve_msg(MSG_RESPONSE_COLOR, this, &fluid_color); + break; + case MSG_RESPONSE_COLOR: + { + RGB *c = ((RGB *)data); + set_color(*c); + } + break; default: IConector::recieve_msg(msg, who, data); } } +void PlantItem::update_color() +{ + if (color_updated) return; + + color_updated = true; + send_msg(IConector::IN, MSG_QUERY_COLOR); +} + +void PlantItem::get_state_as_xml(std::stringstream &out) +{ + out << "\t" << std::endl; + out << "\t\t" << actual_flow << "" << std::endl; + out << "\t" << std::endl; + out << "\t" << std::endl; + out << "\t\t" << fluid_color.r() << "" << std::endl; + out << "\t\t" << fluid_color.g() << "" << std::endl; + out << "\t\t" << fluid_color.b() << "" << std::endl; + out << "\t" << std::endl; + + // Para que quede bonito + actual_flow = INFINITO; +}