5 using namespace PlaQui::Model;
7 PlantItem::PlantItem(const std::string &_name):IConector(0, 0)
11 fluid_color = RGB(255,255,255);
12 color_updated = false;
15 PlantItem::PlantItem(unsigned ins, unsigned outs):IConector(ins, outs)
20 PlantItem::~PlantItem()
24 void PlantItem::recieve_msg(int msg, IConector *who, void *data)
27 case MSG_QUERY_MAX_FLOW_OUT:
33 who->recieve_msg(MSG_RESPONSE_COLOR, this, &fluid_color);
37 who->recieve_msg(MSG_RESPONSE_COLOR, this, &fluid_color);
39 case MSG_RESPONSE_COLOR:
41 RGB *c = ((RGB *)data);
46 IConector::recieve_msg(msg, who, data);
50 void PlantItem::update_color()
52 if (color_updated) return;
55 send_msg(IConector::IN, MSG_QUERY_COLOR);
58 void PlantItem::get_state_as_xml(std::stringstream &out)
60 out << "\t<float name=\"" << name << "\">" << std::endl;
61 out << "\t\t<actual_flow>" << actual_flow << "</actual_flow>" << std::endl;
62 out << "\t</float>" << std::endl;
63 out << "\t<color name=\"" << name << "\">" << std::endl;
64 out << "\t\t<r>" << fluid_color.r() << "</r>" << std::endl;
65 out << "\t\t<g>" << fluid_color.g() << "</g>" << std::endl;
66 out << "\t\t<b>" << fluid_color.b() << "</b>" << std::endl;
67 out << "\t</color>" << std::endl;
69 // Para que quede bonito