typedef struct {
ConnectorType type;
Glib::ustring name_dest;
+ int cistern_connector;
}t_logic_connector;
///Clase que define un conector del item
///Indico que la clase CItem existe para poder compilar.
class CItem;
-///Esta estructura define una linea entre un item logico y uno de transporte.
+/**Esta estructura define una linea entre un item logico y uno de transporte,
+ *tambien indica cual de las dos salidas del tanque esta conectada.
+ */
typedef struct {
int logic_id, store_id;
bool cistern_out1;
#include "and.h"
-
+#include "cistern.h"
And::And(int orientacion)
{
is_logic = true;
dato += c_y;
for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
if ( vec_connector[i].type == IN ) {
- dato += "\t\t<entrada>";
- dato += vec_connector[i].name_dest + "</entrada>\n";
+ if ( vec_connector[i].cistern_connector == 1 ) {
+ dato += "\t\t<entrada><tanque id = \"superior\">";
+ dato += vec_connector[i].name_dest + "</tanque></entrada>\n";
+ }
+ if ( vec_connector[i].cistern_connector == 0 ) {
+ dato += "\t\t<entrada><tanque id = \"inferior\">";
+ dato += vec_connector[i].name_dest + "</tanque></entrada>\n";
+ }
+ if ( vec_connector[i].cistern_connector == -1 ) {
+ dato += "\t\t<entrada>";
+ dato += vec_connector[i].name_dest + "</entrada>\n";
+ }
} else {
dato += "\t\t<salida>";
dato += vec_connector[i].name_dest + "</salida>\n";
if ( (*i).logic_id== ID ) {
temp.type = IN;
temp.name_dest = workplace->get_item((*i).store_id)->get_name();
+ if ( dynamic_cast<Cistern *>(workplace->get_item((*i).store_id)) ) {
+ if ( (*i).cistern_out1 )
+ temp.cistern_connector = 1; //arriba
+ else
+ temp.cistern_connector = 0; //abajo
+ } else
+ temp.cistern_connector = -1; //si no es tanque.
vec_connector.push_back(temp);
}
i++;
combo_entry->set_popdown_strings(*list_pointed);
combo_entry->get_entry()->set_text (name);
if (CItem::logic_connect && CItem::gate_id != -1) {
- if ( detect_click_position((int)event->x, (int)event->y) == IN && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()){
- tmp_line.logic_id = workplace->get_logic_item(CItem::gate_id)->get_id();
- tmp_line.cistern_out1 = true;
- //workplace->get_logic_item(CItem::gate_id)->set_out_connected(true);
- tmp_line.store_id = ID;
- workplace->lista_lineas_out.push_back(tmp_line);
- workplace->queue_draw();
+ if ( detect_click_position((int)event->x, (int)event->y) == IN){
+ if (dynamic_cast<Not *>(workplace->get_logic_item(CItem::gate_id))) {
+ if ( !dynamic_cast<Not *>(workplace->get_logic_item(CItem::gate_id))->get_out_logic_connect()) {
+ workplace->get_logic_item(CItem::gate_id)->set_in_connected(true);
+ tmp_line.logic_id = CItem::gate_id;
+ tmp_line.cistern_out1 = true;
+ tmp_line.store_id = ID;
+ workplace->lista_lineas_out.push_back(tmp_line);
+ workplace->queue_draw();
+ }
+ } else {
+ tmp_line.logic_id = CItem::gate_id;
+ tmp_line.cistern_out1 = true;
+ tmp_line.store_id = ID;
+ workplace->lista_lineas_out.push_back(tmp_line);
+ workplace->queue_draw();
+ }
} else if (detect_click_position((int)event->x, (int)event->y) == OUT ) {
if (dynamic_cast<Not *>(workplace->get_logic_item(CItem::gate_id))) {
if ( !dynamic_cast<Not *>(workplace->get_logic_item(CItem::gate_id))->get_in_logic_connect()) {
} else {
tmp_line.logic_id = CItem::gate_id;
tmp_line.store_id = ID;
+ tmp_line.cistern_out1 = false;
workplace->lista_lineas_out.push_back(tmp_line);
workplace->queue_draw();
}
#include "not.h"
+#include "cistern.h"
Not::Not(int orientacion)
{
dato += c_y;
for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
if ( vec_connector[i].type == IN ) {
- dato += "\t\t<entrada>";
- dato += vec_connector[i].name_dest + "</entrada>\n";
+ if ( vec_connector[i].cistern_connector == 1 ) {
+ dato += "\t\t<entrada><tanque id = \"superior\">";
+ dato += vec_connector[i].name_dest + "</tanque></entrada>\n";
+ }
+ if ( vec_connector[i].cistern_connector == 0 ) {
+ dato += "\t\t<entrada><tanque id = \"inferior\">";
+ dato += vec_connector[i].name_dest + "</tanque></entrada>\n";
+ }
+ if ( vec_connector[i].cistern_connector == -1 ) {
+ dato += "\t\t<entrada>";
+ dato += vec_connector[i].name_dest + "</entrada>\n";
+ }
} else {
dato += "\t\t<salida>";
dato += vec_connector[i].name_dest + "</salida>\n";
if ( (*i).logic_id == ID ) {
temp.type = IN;
temp.name_dest = workplace->get_item((*i).store_id)->get_name();
+ if ( dynamic_cast<Cistern *>(workplace->get_item((*i).store_id)) ) {
+ if ( (*i).cistern_out1 )
+ temp.cistern_connector = 1; //arriba
+ else
+ temp.cistern_connector = 0; //abajo
+ } else
+ temp.cistern_connector = -1; //si no es tanque.
vec_connector.push_back(temp);
cant_in++;
}
#include "or.h"
+#include "cistern.h"
Or::Or(int orientacion)
{
dato += c_y;
for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
if ( vec_connector[i].type == IN ) {
- dato += "\t\t<entrada>";
- dato += vec_connector[i].name_dest + "</entrada>\n";
+ if ( vec_connector[i].cistern_connector == 1 ) {
+ dato += "\t\t<entrada><tanque id = \"superior\">";
+ dato += vec_connector[i].name_dest + "</tanque></entrada>\n";
+ }
+ if ( vec_connector[i].cistern_connector == 0 ) {
+ dato += "\t\t<entrada><tanque id = \"inferior\">";
+ dato += vec_connector[i].name_dest + "</tanque></entrada>\n";
+ }
+ if ( vec_connector[i].cistern_connector == -1 ) {
+ dato += "\t\t<entrada>";
+ dato += vec_connector[i].name_dest + "</entrada>\n";
+ }
} else {
dato += "\t\t<salida>";
dato += vec_connector[i].name_dest + "</salida>\n";
fprintf(archivo, dato.c_str() );
}
+//<entrada><tanque id="superior">tanque1</tanque></entrada>
+
bool Or::check_connection()
{
int cant_in = 0, cant_out =0;
if ( (*i).logic_id== ID ) {
temp.type = OUT;
temp.name_dest = workplace->get_item((*i).store_id)->get_name();
+ temp.cistern_connector = -1;
vec_connector.push_back(temp);
cant_out++;
}
if ( (*i).logic_id== ID ) {
temp.type = IN;
temp.name_dest = workplace->get_item((*i).store_id)->get_name();
+ if ( dynamic_cast<Cistern *>(workplace->get_item((*i).store_id)) ) {
+ if ( (*i).cistern_out1 )
+ temp.cistern_connector = 1; //arriba
+ else
+ temp.cistern_connector = 0; //abajo
+ } else
+ temp.cistern_connector = -1; //si no es tanque.
+ std::cout<<"cistern_connector = "<<temp.cistern_connector<<std::endl;
vec_connector.push_back(temp);
cant_in++;
}
if ( (*i).store_id == ID ) {
temp.type = IN;
temp.name_dest = workplace->get_logic_item((*i).logic_id)->get_name();
+ temp.cistern_connector = -1;
vec_connector.push_back(temp);
cant_out++;
}