-si esta checkeado el boton "logica" haciendo click sobre una compuerta y luego sobre
un item, tira un cable
-si se elimina un item, los cables se borran
-se muevene todos juntos cables+items, pero al rotar un item conectado me falta hacer un repinte
ya lo van a ver...
-el constructor tiene un metodo para borrar todos los itmes pero no hay boton para llamarlo (depues lo pongo)
pero igual la funcion es llamada en el destructor del constructor (con esa los mate)
-en el tanque la bomba y la exclusa los cables se conectan en una posicion mas linda (por lo menos en la exclusa)
-para los cables que salen de las compuertas se me ocurrio discriminar por la posicion donde se clickea en la misma
aunque eso se me hace que va a ser medio incomodo porque son pequenias, pero me parece que estaria bueno igual
-mirenlo y pasen los bugs!
/**Devuelve el tipo de conector que posee en las coordenadas (_a, _b) segun su orientacion
*/
virtual ConnectorType get_connector_type(int _a, int _b);
+
+ /**Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
+ */
+ virtual void get_logic_connect_position(int& _a, int& _b);
protected:
/**Atributos que definen su comportamiento
*/
WorkPlace *workplace;
bool logica;
bool can_drop(CItem *, int , int);
+
// /señales de control para los elementos de la ventana.
-
virtual void on_btn_canio_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_btn_y_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_btn_codo_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_main_menu_open();
virtual void on_main_menu_save();
virtual void on_edit_menu_del();
+ virtual void on_edit_menu_delete_all();
virtual void on_chk_btn_clicked();
virtual void on_btn_open_cancel_clicked();
virtual void on_btn_file_ok_clicked();
/**Devuelve el tipo de conector que posee en las coordenadas (_a, _b) segun su orientacion
*/
virtual ConnectorType get_connector_type(int _a, int _b);
+
+ /**Los valores _a y _b se setean en el punto donde se deben conectar los cables logicos
+ */
+ virtual void get_logic_connect_position(int& _a, int& _b);
+
/**Funciones para obtener y setear sus propiedades
*/
void set_estado(bool _state);
///TODO: hacer abstractas estas funciones... en item no hacen nada....
virtual void set_default_connector();
virtual ConnectorType get_connector_type( int _a, int _b );
+ virtual void get_logic_connect_position(int& _a, int& _b);
///Puntero al area de trabajo de la ventana principal
WorkPlace *workplace;
virtual void set_default_connector();
///Devuelve el tipo de conector que posee en las coordenadas (_a,_b) segun su orientacion
virtual ConnectorType get_connector_type(int _a, int _b);
+ ///Setea las coordenadas _a, _b en la posicion donde se deben conectar los cables logicos.
+ virtual void get_logic_connect_position(int& _a, int& _b);
protected:
///Indica la maxima capacidad de entrega de la bomba
double entrega;
CItem *get_logic_item(int _id);
std::list<CItem *> *listaItems, *lista_logic_Items;
std::list<t_line> lista_lineas;
+ static int pointed;
};
#endif
bool And::on_button_press_event(GdkEventButton *event)
{
- if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
+ if (CItem::logic_connect)
+ CItem::quien = ID;
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
+ }
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
image = null;
t_line tmp_line;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
if (CItem::logic_connect) {
tmp_line.logic = workplace->get_logic_item(CItem::quien);
tmp_line.store = this;
workplace->lista_lineas.push_back(tmp_line);
workplace->on_expose_event(&e);
}
- CItem::logic_connect = false;
}
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
cistern_pty_wnd->txt_cistern_name->set_text( name );
cistern_pty_wnd->show();
}
+ workplace->on_expose_event(&e);
return true;
}
connect_vec[0].type = IN;
connect_vec[1].type = OUT;
}
+
+void Cistern::get_logic_connect_position(int& _a, int& _b)
+{
+ switch(imgActual) {
+ case 0:
+ _a = x;
+ _b = y + 10;
+ break;
+ case 1:
+ _a = x +image->get_width();
+ _b = y + 10;
+ }
+}
bool Conduct::on_button_press_event(GdkEventButton *event)
{
- int w, h;
- if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
+ }
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
image = null;
imgActual = 0;
image = imageN;
}
- get_size_request(w, h);
- set_size_request(h, w);
+ set_size_request(image->get_width(), image->get_height());
image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
}
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
Constructor::~Constructor()
{
- std::list<CItem *>::iterator i = listaItems.begin();
- while ( i != listaItems.end() ){
- CItem *temp = *i;
- listaItems.erase(i);
- delete temp;
- i = listaItems.begin();
- }
+ Constructor::on_edit_menu_delete_all();
}
void Constructor::on_btn_canio_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
}
void Constructor::on_edit_menu_del()
-{ // OJO que borra al primero que encuentra con el mismo nombre!!!
+{
+ workplace->delete_item(WorkPlace::pointed);
+}
+
+void Constructor::on_edit_menu_delete_all()
+{
std::list<CItem *>::iterator i = listaItems.begin();
- Glib::ustring pointed = combo_entry->get_text();
- while ( i != listaItems.end() ){
- CItem *temp = *i;
- if ( temp->get_name() == pointed ){
- workplace->delete_item(temp->get_id());
- break;
- }
- i++;
+ while ( i != listaItems.end() ) {
+ (*i)->workplace->delete_item((*i)->get_id());
+ i = listaItems.begin();
+ }
+ i = lista_logic_Items.begin();
+ while ( i != lista_logic_Items.end() ) {
+ (*i)->workplace->delete_item((*i)->get_id());
+ i=lista_logic_Items.begin();
}
}
void Constructor::on_chk_btn_clicked()
{
logica = !logica;
+ CItem::logic_connect = !CItem::logic_connect;
}
void Constructor::on_load_from_xml()
}
std::cout << "CARGA COMPLETA" << std::endl;
file_open_selection->hide();
+ id = listaItems.size()+lista_logic_Items.size()+1;
}
void Constructor::on_btn_file_ok_clicked()
{
return p;
}
-
bool Drain::on_button_press_event(GdkEventButton *event)
{
- if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
+ }
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
image = null;
t_line tmp_line;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
if (CItem::logic_connect) {
tmp_line.logic = workplace->get_logic_item(CItem::quien);
tmp_line.store = this;
workplace->lista_lineas.push_back(tmp_line);
workplace->on_expose_event(&e);
- }
- CItem::logic_connect = false;
+ }
}
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
exclusa_pty_wnd->show();
}
+ workplace->on_expose_event(&e);
return true;
}
return UNDEF;
}
+void Exclusa::get_logic_connect_position(int& _a, int& _b)
+{
+ switch (imgActual) {
+ case 0:
+ _a = x + image->get_width()/2;
+ _b = y;
+ break;
+ case 1:
+ _a = x + image->get_width();
+ _b = y + image->get_height()/2;
+ }
+}
+
void Exclusa::set_default_connector()
{
connect_vec[0].type = UNDEF;
#include "item.h"
-bool CItem:: logic_connect = false;
+bool CItem::logic_connect = false;
int CItem::quien = -1;
void CItem::on_menu_popup_conectar()
{
- CItem::logic_connect = true;
- CItem::quien = ID;
}
int CItem::get_position_x()
void CItem::set_default_connector()
{
}
+
+void CItem::get_logic_connect_position(int& _a, int& _b)
+{
+ _a = x;
+ _b = y;
+}
bool Not::on_button_press_event(GdkEventButton *event)
{
- if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
+ if (CItem::logic_connect)
+ CItem::quien = ID;
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
+ }
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
image = null;
bool Or::on_button_press_event(GdkEventButton *event)
{
- if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
+ if (CItem::logic_connect)
+ CItem::quien = ID;
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
+ }
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
image = null;
t_line tmp_line;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
if (CItem::logic_connect) {
tmp_line.logic = workplace->get_logic_item(CItem::quien);
tmp_line.store = this;
workplace->lista_lineas.push_back(tmp_line);
workplace->on_expose_event(&e);
}
- CItem::logic_connect = false;
}
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
pump_pty_wnd->txt_pump_name->set_text( name );
pump_pty_wnd->show();
}
+ workplace->on_expose_event(&e);
return true;
}
{
connect_vec[0].type = OUT;
}
+
+void Pump::get_logic_connect_position(int& _a, int& _b)
+{
+ switch(imgActual) {
+ case 0:
+ _a = x + image->get_width() - 10;
+ _b = y;
+ break;
+ case 1:
+ _a = x + 10;
+ _b = y;
+ }
+}
bool Splitter::on_button_press_event(GdkEventButton *event)
{
- if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
+ }
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
image = null;
bool Union::on_button_press_event(GdkEventButton *event)
{
- if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
combo_entry->set_text(name);
+ WorkPlace::pointed = ID;
+ }
if ((event->type == GDK_BUTTON_PRESS) && (event->button == 2 )){
image = null;
#include "workplace.h"
#include "item.h"
+int WorkPlace::pointed = -1;
+
WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
{
}
color.set_rgb(255,0,0);
gc->set_rgb_bg_color(color);
get_style()->set_black(color);
+ int w, z;
std::list<t_line>::iterator i = lista_lineas.begin();
while ( i != lista_lineas.end() ) {
t_line temp = *i;
- get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), temp.store->get_position_x(),temp.store->get_position_y());
+ temp.store->get_logic_connect_position(w,z);
+ get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
i++;
}
return true;
void WorkPlace::delete_item(int _id)
{
+ CItem::logic_connect = false;
std::list<CItem*>::iterator i = listaItems->begin();
while ( i != listaItems->end() ){
CItem *temp = *i;
CItem *temp = *i;
if ( temp->get_id() == _id ){
delete_line(_id);
- listaItems->erase(i);
+ lista_logic_Items->erase(i);
delete temp;
break;
}
{
std::list<t_line>::iterator i = lista_lineas.begin();
while ( i != lista_lineas.end() ){
- if ( ((*i).logic->get_id() == _id) || ((*i).store->get_id() == _id) )
+ if ( (*i).store->get_id() == _id ) {
lista_lineas.erase(i);
+ i = lista_lineas.begin();
+ }
i++;
}
+ i = lista_lineas.begin();
+ while ( i != lista_lineas.end() ){
+ if ( (*i).logic->get_id() == _id ) {
+ lista_lineas.erase(i);
+ i = lista_lineas.begin();
+ }
+ i++;
+ }
}