]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
despues de estar como un pelotudo buscando el error, lo encontre, era un == ( yo...
authorNicolás Dimov <ndimov@gmail.com>
Sun, 30 Nov 2003 22:53:13 +0000 (22:53 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Sun, 30 Nov 2003 22:53:13 +0000 (22:53 +0000)
Constructor/include/item.h
Constructor/include/workplace.h
Constructor/src/and.cpp
Constructor/src/cistern.cpp
Constructor/src/not.cpp
Constructor/src/or.cpp

index 7b277e3f08549b986b951ae421700f8e9540ea1b..3259d8d1170acf472cad7d8ca6d8f6d6ff0e9d35 100644 (file)
@@ -25,6 +25,7 @@ typedef enum { UNDEF, IN, OUT } ConnectorType;
 typedef struct {
        ConnectorType type;
        Glib::ustring name_dest;
+       int cistern_connector;
 }t_logic_connector;
 
 ///Clase que define un conector del item
index a559f37c2b7da738d641b01e7253e6be9d024789..c85d76aeb3a6691e5beb2de239e4c0fc7081f5b9 100644 (file)
@@ -12,7 +12,9 @@
 ///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;
index 504747b2cfd58d592ca02606831dd4478faa9111..86b774fa2a1935c4072fe85f2645d9e8892ee119 100644 (file)
@@ -1,5 +1,5 @@
 #include "and.h"
-
+#include "cistern.h"
 And::And(int orientacion)
 {
        is_logic = true;
@@ -153,8 +153,18 @@ void And::save(FILE *archivo)
        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";
@@ -182,6 +192,13 @@ bool And::check_connection()
                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++;
index 2db315f59c500ff7071c8e0ec8191cc295493ca4..bdc2190e3bf7fdb4209b848d3f022c6aeb83b9f2 100644 (file)
@@ -52,13 +52,23 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                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()) {
@@ -72,6 +82,7 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                                } 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();
                                }                                       
index 2be71fec1026fb81bd6b6e865a7fd72869edfe20..e69a94a1a2f31e38972a8302cd9fabc1b1637fb1 100644 (file)
@@ -1,4 +1,5 @@
 #include "not.h"
+#include "cistern.h"
 
 Not::Not(int orientacion)
 {
@@ -155,8 +156,18 @@ void Not::save(FILE *archivo)
        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";
@@ -186,6 +197,13 @@ bool Not::check_connection()
                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++;
                }
index ee96e2287ae7c249906a5eaa1a111e8e5feee23e..2c17f7aaeb81909938e32a908fb189a7d0dfdb47 100644 (file)
@@ -1,4 +1,5 @@
 #include "or.h"
+#include "cistern.h"
 
 Or::Or(int orientacion)
 {
@@ -152,8 +153,18 @@ void Or::save(FILE *archivo)
        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";
@@ -163,6 +174,8 @@ void Or::save(FILE *archivo)
        fprintf(archivo, dato.c_str() );
 }
 
+//<entrada><tanque id="superior">tanque1</tanque></entrada>
+
 bool Or::check_connection()
 {
        int cant_in = 0, cant_out =0;
@@ -172,6 +185,7 @@ bool Or::check_connection()
                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++;
                }
@@ -183,6 +197,14 @@ bool Or::check_connection()
                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++;
                }
@@ -205,6 +227,7 @@ bool Or::check_connection()
                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++;
                }