From: Nicolás Dimov Date: Sat, 8 Nov 2003 21:20:59 +0000 (+0000) Subject: estoy completando un poco todo esto para ponerme a implementar el guardar y cargar... X-Git-Tag: svn_import~327 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/07f4e929e15451f6af8ec4d941bcee6742917d0d?ds=inline;hp=0aacdcf95cf6d4f33a2201160d472ab84148d52b estoy completando un poco todo esto para ponerme a implementar el guardar y cargar, pero tengo un quilombo con las referencias cruzadas (creo) y no compila. Lo raro es que es un caso totalmente analogo a otro que si anda. si pueden peguenle una mirada rapida para ver si se dan cuenta donde esta el error. --- diff --git a/Constructor/activezone.cpp b/Constructor/activezone.cpp index 014439e..ee426b0 100644 --- a/Constructor/activezone.cpp +++ b/Constructor/activezone.cpp @@ -8,8 +8,15 @@ ActiveZone::~ActiveZone() { } -bool ActiveZone::on_button_press_event(GdkEventButton *e) +bool ActiveZone::on_button_press_event(GdkEventButton *event) +{ + if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) { + get_pointer(temp.x,temp.y); + } + return true; +} + +bool ActiveZone::on_button_release_event(GdkEventButton *event) { - std::cout<< "hola vieja"< #include #include #include +#include "workplace.h" + +typedef struct { + int x,y,w,z; +}t_line; + +class WorkPlace; class ActiveZone:public Gtk::Viewport { public: ActiveZone(BaseObjectType* cobject, const Glib::RefPtr &refGlade); virtual ~ActiveZone(); virtual bool on_button_press_event(GdkEventButton *e); + virtual bool on_button_release_event(GdkEventButton *e); + t_line temp; + std::list lista_lineas; + WorkPlace *workplace; }; - +#endif diff --git a/Constructor/cistern.cpp b/Constructor/cistern.cpp index 1495443..fdb9aa1 100644 --- a/Constructor/cistern.cpp +++ b/Constructor/cistern.cpp @@ -2,8 +2,6 @@ Cistern::Cistern() { - caudal = 56; - fluido_max = 23; imageE = Gdk::Pixbuf::create_from_file("tanque_e.png"); imageO = Gdk::Pixbuf::create_from_file("tanque_o.png"); null = Gdk::Pixbuf::create_from_file("tanque_null.png"); @@ -11,14 +9,9 @@ Cistern::Cistern() image = imageE; set_size_request(image->get_width(), image->get_height()); - Glib::RefPtr ref; - try { - ref = Gnome::Glade::Xml::create("constructor.glade", "cistern_pty_wnd"); - } - catch(const Gnome::Glade::XmlError &ex) { - std::cerr << ex.what() << std::endl; - } + Glib::RefPtr ref = Gnome::Glade::Xml::create("constructor.glade", "cistern_pty_wnd"); ref->get_widget_derived("cistern_pty_wnd",cistern_pty_wnd); + cistern_pty_wnd->cistern = this; } Cistern::~Cistern() @@ -49,8 +42,9 @@ bool Cistern::on_button_press_event(GdkEventButton *event) } if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){ - cistern_pty_wnd->spin_caudal->set_value((double)x); - cistern_pty_wnd->spin_fluido_max->set_value((double)y); + cistern_pty_wnd->spin_capacidad->set_value( capacidad ); + cistern_pty_wnd->spin_inicial->set_value( contenido_inicial ); + cistern_pty_wnd->txt_cistern_name->set_text( name ); cistern_pty_wnd->show(); } return true; @@ -66,11 +60,28 @@ void Cistern::on_menu_popup_rotar() void Cistern::on_menu_popup_propiedades() { -// cistern_pty_wnd->spin_caudal->set_value(caudal); -// cistern_pty_wnd->spin_fluido_max->set_value(fluido_max); - std::cout<< "posicion = "<< x <<" "<< y < +class CisternPtyWnd; + class Cistern : public CItem { public: Cistern(); @@ -13,13 +14,16 @@ class Cistern : public CItem { virtual bool on_button_press_event(GdkEventButton *event); virtual void on_menu_popup_rotar(); virtual void on_menu_popup_propiedades(); + void set_capacidad(double _cap); + double get_capacidad(); + void set_contenido_inicial(double _ini); + double get_contenido_inicial(); protected: - double caudal, fluido_max; + double capacidad, contenido_inicial; int imgActual; Glib::RefPtr imageE; // 0 Glib::RefPtr imageO; // 1 Glib::RefPtr null; - CisternPtyWnd *cistern_pty_wnd; }; #endif diff --git a/Constructor/cisternptywnd.cpp b/Constructor/cisternptywnd.cpp deleted file mode 100644 index 5ef0ec1..0000000 --- a/Constructor/cisternptywnd.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "cisternptywnd.h" - -CisternPtyWnd::CisternPtyWnd(BaseObjectType* cobject, const Glib::RefPtr& refGlade):PropertyWnd(cobject,refGlade) -{ - refGlade->get_widget("spin_caudal", spin_caudal); - refGlade->get_widget("spin_fluido_max", spin_fluido_max); -} - -CisternPtyWnd::~CisternPtyWnd() -{ -} - -void CisternPtyWnd::on_btn_accept_clicked() -{ - hide(); -} diff --git a/Constructor/cisternptywnd.h b/Constructor/cisternptywnd.h deleted file mode 100644 index e910ac7..0000000 --- a/Constructor/cisternptywnd.h +++ /dev/null @@ -1,17 +0,0 @@ -//cisternptywnd.h -#ifndef _CISTERNPTYWND_H_ -#define _CISTERNPTYWND_H_ - -#include "propertywnd.h" - -class CisternPtyWnd : public PropertyWnd { - public: - CisternPtyWnd(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - virtual ~CisternPtyWnd(); - //protected: - Gtk::SpinButton *spin_caudal, *spin_fluido_max; - virtual void on_btn_accept_clicked(); -}; - - -#endif diff --git a/Constructor/conduct.cpp b/Constructor/conduct.cpp index a28aa79..61d3922 100644 --- a/Constructor/conduct.cpp +++ b/Constructor/conduct.cpp @@ -8,15 +8,6 @@ Conduct::Conduct() imgActual = 0; image = imageN; set_size_request(image->get_width(), image->get_height()); - - Glib::RefPtr ref; - try { - ref = Gnome::Glade::Xml::create("constructor.glade", "conduct_pty_wnd"); - } - catch(const Gnome::Glade::XmlError &ex) { - std::cerr << ex.what() << std::endl; - } - ref->get_widget_derived("conduct_pty_wnd",property_wnd); } Conduct::~Conduct() @@ -48,7 +39,9 @@ bool Conduct::on_button_press_event(GdkEventButton *event) } if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){ - property_wnd->show(); + property_wnd->spin_caudal->set_value( caudal_max ); + property_wnd->txt_item_name->set_text (name); + property_wnd->show(); } return true; } diff --git a/Constructor/constructor.cpp b/Constructor/constructor.cpp index af1263b..7553c91 100644 --- a/Constructor/constructor.cpp +++ b/Constructor/constructor.cpp @@ -176,17 +176,19 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtrlength >= 0) && (selection_data->format == 8)) { CItem *a; if (strcmp((const char *)selection_data->data, "item_codo.png")==0) - a = new Splitter();//Gtk::manage( new Splitter() ); + a = new Splitter(); else if (strcmp((const char *)selection_data->data, "item_canio.png")==0) - a = new Conduct();//Gtk::manage( new Conduct() ); + a = new Conduct(); else if (strcmp((const char *)selection_data->data, "item_y.png")==0) - a = new Union();//Gtk::manage( new Union() ); + a = new Union(); else if (strcmp((const char *)selection_data->data, "item_tanque.png")==0) - a = new Cistern();//Gtk::manage( new Cistern() ); + a = new Cistern(); else - a = new CItem();//Gtk::manage( new CItem((const char *)selection_data->data) ); + a = new CItem(); //Seteo el ID del item + Glib::ustring name("item"); a->set_id(++id); + a->set_name( name ); if ( can_drop(a, i*32, j*32) ) { workplace->put(*a, i*32, j*32); //Apunto al workplace diff --git a/Constructor/constructor.glade b/Constructor/constructor.glade index 94c1976..5325328 100644 --- a/Constructor/constructor.glade +++ b/Constructor/constructor.glade @@ -295,8 +295,8 @@ True - GTK_BUTTONBOX_SPREAD - 0 + GTK_BUTTONBOX_START + 5 @@ -426,8 +426,8 @@ True - GTK_BUTTONBOX_SPREAD - 0 + GTK_BUTTONBOX_START + 5 @@ -557,73 +557,10 @@ 0 0 - - - True - True - 1 - 1 - True - GTK_UPDATE_ALWAYS - False - False - 0 0 10000 0.1 10 10 - - - 1 - 2 - 0 - 1 - - - - - - - True - True - 1 - 1 - True - GTK_UPDATE_ALWAYS - False - False - 0 0 10000 0.1 10 10 - - - 1 - 2 - 1 - 2 - - - - - - - True - True - 1 - 1 - True - GTK_UPDATE_ALWAYS - False - False - 0 0 100 0.1 10 10 - - - 1 - 2 - 2 - 3 - - - - True - Capacidad Máxima + Contenido Inicial False False GTK_JUSTIFY_LEFT @@ -647,7 +584,7 @@ True - Fluido Máximo + Capacidad Máxima False False GTK_JUSTIFY_LEFT @@ -669,9 +606,9 @@ - + True - Otro + Nombre False False GTK_JUSTIFY_LEFT @@ -691,6 +628,69 @@ + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + + + + + True + True + 1 + 1 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 100 0.1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + 1 + 1 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 100 0.1 10 10 + + + 1 + 2 + 0 + 1 + + + 0 @@ -703,8 +703,8 @@ - - Propiedades del Tubo + + Propiedades del GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -770,14 +770,14 @@ True - 3 + 2 2 True 0 0 - + True True 1 @@ -822,51 +822,9 @@ - + True - True - 1 - 1 - False - GTK_UPDATE_ALWAYS - False - False - 0 0 100 0.1 10 10 - - - 1 - 2 - 1 - 2 - - - - - - - True - True - 1 - 1 - False - GTK_UPDATE_ALWAYS - False - False - 0 0 100 0.1 10 10 - - - 1 - 2 - 2 - 3 - - - - - - - True - Longitud + Nombre False False GTK_JUSTIFY_LEFT @@ -888,25 +846,22 @@ - + True - Otro - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 + True + True + True + 0 + + True + * + False - 0 - 1 - 2 - 3 - fill + 1 + 2 + 1 + 2 @@ -922,4 +877,33 @@ + + 10 + Select File + GTK_WINDOW_POPUP + GTK_WIN_POS_NONE + False + True + False + True + + + + True + True + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + diff --git a/Constructor/item.cpp b/Constructor/item.cpp index b4a42fe..c2410d5 100644 --- a/Constructor/item.cpp +++ b/Constructor/item.cpp @@ -9,6 +9,11 @@ CItem::CItem(const char *filename):Gtk::DrawingArea() CItem::CItem() { + Glib::RefPtr ref; + ref = Gnome::Glade::Xml::create("constructor.glade", "item_pty_wnd"); + ref->get_widget_derived("item_pty_wnd",property_wnd); + caudal_max = 0.0; + property_wnd->item = this; menu_image_propiedades.set(Gtk::Stock::PREFERENCES, Gtk::ICON_SIZE_MENU); menu_image_delete.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU); menu_image_rotar.set(Gtk::Stock::REFRESH, Gtk::ICON_SIZE_MENU); @@ -86,3 +91,23 @@ int CItem::get_id() { return ID; } + +void CItem::set_caudal(double _caudal) +{ + caudal_max = _caudal; +} + +double CItem::get_caudal() +{ + return caudal_max; +} + +void CItem::set_name(Glib::ustring _name) +{ + name = _name; +} + +Glib::ustring CItem::get_name() +{ + return name; +} diff --git a/Constructor/item.h b/Constructor/item.h index 87aaaed..f9e460c 100644 --- a/Constructor/item.h +++ b/Constructor/item.h @@ -8,7 +8,7 @@ #include #include #include -#include "propertywnd.h" +#include "itemptywnd.h" #include "workplace.h" class WorkPlace; @@ -30,13 +30,19 @@ public: bool is_occupied_area(int _a, int _b); void set_id(int _id); int get_id(); + void set_caudal(double _caudal); + double get_caudal(); + void set_name(Glib::ustring _name); + Glib::ustring get_name(); WorkPlace *workplace; protected: int ID; + Glib::ustring name; + double caudal_max; Gtk::Menu menu_popup; Gtk::Image menu_image_delete, menu_image_rotar, menu_image_propiedades, menu_image_linea; Glib::RefPtr image; - PropertyWnd *property_wnd; + ItemPtyWnd *property_wnd; int x, y; }; diff --git a/Constructor/itemptywnd.cpp b/Constructor/itemptywnd.cpp new file mode 100644 index 0000000..d1d00c8 --- /dev/null +++ b/Constructor/itemptywnd.cpp @@ -0,0 +1,29 @@ +#include "itemptywnd.h" + +ItemPtyWnd::ItemPtyWnd(BaseObjectType* cobject, const Glib::RefPtr& refGlade):PropertyWnd(cobject,refGlade) +{ + refGlade->get_widget("spin_caudal", spin_caudal); + refGlade->get_widget("txt_item_name",txt_item_name); +} + +ItemPtyWnd::~ItemPtyWnd() +{ +} + +void ItemPtyWnd::on_btn_accept_clicked() +{ + item->set_caudal( spin_caudal->get_value() ); + item->set_name( txt_item_name->get_text() ); + hide(); +} + +void ItemPtyWnd::on_btn_apply_clicked() +{ + item->set_caudal( spin_caudal->get_value() ); + item->set_name( txt_item_name->get_text() ); +} + +void ItemPtyWnd::on_btn_cancel_clicked() +{ + hide(); +} diff --git a/Constructor/itemptywnd.h b/Constructor/itemptywnd.h new file mode 100644 index 0000000..daaa32e --- /dev/null +++ b/Constructor/itemptywnd.h @@ -0,0 +1,19 @@ +//cisternptywnd.h +#ifndef _CISTERNPTYWND_H_ +#define _CISTERNPTYWND_H_ + +#include "propertywnd.h" + +class ItemPtyWnd : public PropertyWnd { + public: + ItemPtyWnd(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + virtual ~ItemPtyWnd(); + Gtk::SpinButton *spin_caudal; + Gtk::Entry *txt_item_name; + virtual void on_btn_cancel_clicked(); + virtual void on_btn_accept_clicked(); + virtual void on_btn_apply_clicked(); +}; + + +#endif diff --git a/Constructor/propertywnd.cpp b/Constructor/propertywnd.cpp index 7c0c000..1bd3643 100644 --- a/Constructor/propertywnd.cpp +++ b/Constructor/propertywnd.cpp @@ -1,5 +1,3 @@ -//propertywnd.cpp - #include "propertywnd.h" PropertyWnd::PropertyWnd() @@ -14,6 +12,7 @@ PropertyWnd::PropertyWnd(BaseObjectType* cobject, const Glib::RefPtrsignal_clicked().connect(SigC::slot(*this, &PropertyWnd::on_btn_cancel_clicked)); btn_accept->signal_clicked().connect(SigC::slot(*this, &PropertyWnd::on_btn_accept_clicked)); + btn_apply->signal_clicked().connect(SigC::slot(*this, &PropertyWnd::on_btn_apply_clicked)); } PropertyWnd::~PropertyWnd() @@ -29,3 +28,7 @@ void PropertyWnd::on_btn_cancel_clicked() void PropertyWnd::on_btn_accept_clicked() { } + +void PropertyWnd::on_btn_apply_clicked() +{ +} diff --git a/Constructor/propertywnd.h b/Constructor/propertywnd.h index 2c068a8..ef8fbdf 100644 --- a/Constructor/propertywnd.h +++ b/Constructor/propertywnd.h @@ -1,23 +1,26 @@ -//propertywnd.h #ifndef _PROPERTYWND_H_ #define _PROPERTYWND_H_ #include #include #include +#include #include +#include "item.h" +class CItem; + class PropertyWnd : public Gtk::Window{ public: PropertyWnd(); PropertyWnd(BaseObjectType* cobject, const Glib::RefPtr& refGlade); virtual ~PropertyWnd(); - + CItem *item; protected: Gtk::Button *btn_cancel, *btn_accept, *btn_apply; virtual void on_btn_cancel_clicked(); virtual void on_btn_accept_clicked(); - + virtual void on_btn_apply_clicked(); }; diff --git a/Constructor/workplace.cpp b/Constructor/workplace.cpp index 3baa408..418f6b7 100644 --- a/Constructor/workplace.cpp +++ b/Constructor/workplace.cpp @@ -3,7 +3,7 @@ WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr &refGlade):Gtk::Fixed(cobject) { refGlade->get_widget_derived("viewport",viewport); - this->signal_button_press_event().connect(SigC::slot(*this,&WorkPlace::on_button_press_event)); + viewport->workplace = this; } WorkPlace::~WorkPlace() @@ -21,28 +21,14 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event) get_window()->draw_point (get_style()->get_black_gc(), x+1,y); get_window()->draw_point (get_style()->get_black_gc(), x-1,y); } - //TODO recorer la lista_lineas y dibujar todas - get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z); return true; } - bool WorkPlace::on_button_press_event(GdkEventButton *event) { - std::cout<< temp.x<<" "<type == GDK_BUTTON_PRESS) && (event->button == 1) ) { - get_pointer(temp.x,temp.y); - std::cout<< temp.x<<" "<type == GDK_BUTTON_PRESS) && (event->button == 1) ) { - get_pointer(temp.w,temp.z); - lista_lineas.push_back(temp); - get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z); + if ((event->type==GDK_BUTTON_RELEASE) && (event->button ==1)) { + get_pointer(viewport->temp.w, viewport->temp.z); + get_window()->draw_line (get_style()->get_black_gc(), viewport->temp.x,viewport->temp.y,viewport->temp.w,viewport->temp.z); } return true; } diff --git a/Constructor/workplace.h b/Constructor/workplace.h index 6d81e4f..0677da3 100644 --- a/Constructor/workplace.h +++ b/Constructor/workplace.h @@ -8,22 +8,16 @@ #include "activezone.h" #include "item.h" -typedef struct { - int x,y,w,z; -}t_line; - class CItem; +class ActiveZone; class WorkPlace:public Gtk::Fixed { public: WorkPlace(BaseObjectType* cobject, const Glib::RefPtr &refGlade); virtual ~WorkPlace(); virtual bool on_expose_event(GdkEventExpose *event); - virtual bool on_button_press_event(GdkEventButton *event); - virtual bool on_button_release_event(GdkEventButton *event); + virtual bool on_button_press_event (GdkEventButton *event); void delete_item(int _id); - std::list lista_lineas; - t_line temp; std::list *listaItems; ActiveZone *viewport; };