From e87ccf6dd21c4739331f33891111c0a006bec002 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Thu, 27 Nov 2003 22:49:58 +0000 Subject: [PATCH] * Se agrega dialogo de propiedades para setear la velocidad de actualizacion * Se agregan botones "simular" y "pausar" para manejar la simulacion --- Client/AUTHORS | 2 +- Client/dialogs/client.glade | 160 ++++++++++++++++++++++++++++++++++-- Client/include/principal.h | 9 +- Client/src/Makefile.am | 1 + Client/src/principal.cpp | 53 +++++++++++- 5 files changed, 211 insertions(+), 14 deletions(-) diff --git a/Client/AUTHORS b/Client/AUTHORS index 4b11b05..baf43b5 100644 --- a/Client/AUTHORS +++ b/Client/AUTHORS @@ -14,6 +14,6 @@ Special Thanks to Eric Raymond Linus Torvals Richard Stallman - Gtk+ Deleveloper Team + Gtk+ Delevelopment Team The Free Software community diff --git a/Client/dialogs/client.glade b/Client/dialogs/client.glade index 1ca5be1..f141e54 100644 --- a/Client/dialogs/client.glade +++ b/Client/dialogs/client.glade @@ -208,23 +208,25 @@ - + True - Desconectar + Simular True + gtk-refresh + True + + True + - + True - gtk-quit - True - True + Pausar + True + gtk-cancel - - True - @@ -1153,4 +1155,144 @@ + + Propiedades + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + True + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 3 + 3 + False + 0 + 0 + + + + True + Velocidad de Simulación : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 1 + 2 + 0 + 1 + + + + + + + True + veces/segundos + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + 0 + True + True + + + + + + diff --git a/Client/include/principal.h b/Client/include/principal.h index 5555524..5c8e368 100644 --- a/Client/include/principal.h +++ b/Client/include/principal.h @@ -6,6 +6,7 @@ #include #include #include "dlg_conectar.h" +#include "dlg_property.h" #include "plaqui/server/controlclient.h" #include #include @@ -50,12 +51,13 @@ protected: ViewItem *last_selected; // Dialogo de Conectar DlgConectar *dlg_conectar; + DlgProperty *dlg_property; Gtk::Entry *txt_target, *txt_command, *txt_args; Gtk::TextView *txt_view; Gtk::Fixed *work_place; Gtk::Label *lbl_nombre, *lbl_color, *lbl_flujo, *lbl_extra, *lbl_cap_flujo, *lbl_cap_extra; Gtk::Image *ico_conected; - Gtk::Button *btn_activar; + Gtk::Button *btn_activar, *btn_simulate, *btn_pause; Gtk::DrawingArea *color_preview; // Actualiza las propiedades en la ventana del item actual @@ -66,10 +68,13 @@ protected: virtual void on_mnu_file_connect(); virtual void on_mnu_file_disconnect(); virtual void on_mnu_help_about(); + virtual void on_mnu_property(); + virtual void on_dlg_property_ok(); virtual void on_dlg_connect_ok(); virtual void on_get_clicked(); virtual void on_btn_activar_clicked(); - + virtual void on_btn_simulate_clicked(); + virtual void on_btn_pause_clicked(); virtual bool on_item_clicked(GdkEventButton *, ViewItem *); // Callbacks para las conexiones diff --git a/Client/src/Makefile.am b/Client/src/Makefile.am index c2e20b4..608e64e 100644 --- a/Client/src/Makefile.am +++ b/Client/src/Makefile.am @@ -12,6 +12,7 @@ bin_PROGRAMS = plaqui-client plaqui_client_SOURCES = main.cpp \ principal.cpp \ dlg_conectar.cpp \ + dlg_property.cpp \ item.cpp \ item_pump.cpp \ item_codo.cpp \ diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index fab7552..cb4a853 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -21,7 +21,10 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & txt_target = txt_command = txt_args = 0; work_place = 0; lbl_cap_flujo = lbl_cap_extra = lbl_extra = lbl_nombre = lbl_color = lbl_flujo = 0; + btn_simulate = btn_pause = 0; + rg->get_widget("btn_pausa", btn_pause); + rg->get_widget("btn_simular", btn_simulate); rg->get_widget("btn_activar", btn_activar); rg->get_widget("color_preview", color_preview); rg->get_widget("lbl_nombre", lbl_nombre); @@ -34,6 +37,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & rg->get_widget("mnu_file_exit", exit); rg->get_widget("mnu_help_about", about); rg->get_widget("mnu_prop", mnu_prop); + rg->get_widget_derived("dlg_property", dlg_property); rg->get_widget_derived("dlgConectar", dlg_conectar); rg->get_widget("btn_get", btn_get); rg->get_widget("txt_view", txt_view); @@ -44,7 +48,9 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & rg->get_widget("work_place", work_place); rg->get_widget("ico_conected", ico_conected); + dlg_property->get_ok_button()->signal_clicked().connect( SigC::slot(*this, &Principal::on_dlg_property_ok) ); dlg_conectar->get_ok_button()->signal_clicked().connect( SigC::slot(*this, &Principal::on_dlg_connect_ok) ); + mnu_prop->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_property)); mnu_disconnect->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_disconnect)); conect->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_connect)); bar_connect->signal_clicked().connect( SigC::slot(*this, &Principal::on_mnu_file_connect)); @@ -52,7 +58,9 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & about->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_help_about)); btn_get->signal_clicked().connect( SigC::slot(*this, &Principal::on_get_clicked) ); btn_activar->signal_clicked().connect( SigC::slot(*this, &Principal::on_btn_activar_clicked) ); - + btn_simulate->signal_clicked().connect( SigC::slot(*this, &Principal::on_btn_simulate_clicked) ); + btn_pause->signal_clicked().connect( SigC::slot(*this, &Principal::on_btn_pause_clicked) ); + conexion = NULL; is_xml_loaded = false; last_selected = NULL; @@ -138,7 +146,7 @@ void Principal::on_mnu_file_disconnect() c2.add_arg(conexion->get_host()); c2.add_arg(conexion->get_port()); conexion->send(c2); - //conexion->finish(); + } void Principal::on_mnu_file_connect() @@ -223,6 +231,12 @@ void Principal::on_conexion_finished() txt_view->get_buffer()->insert_at_cursor("HANG UP\n"); ico_conected->set( Gtk::Stock::NO , Gtk::IconSize(Gtk::ICON_SIZE_LARGE_TOOLBAR)); conexion = NULL; + // Elimino la planta + std::map::iterator i; + for(i=mapItems.begin(); i!=mapItems.end(); i++) { + delete i->second; + } + mapItems.clear(); } void Principal::on_conexion_ok(const std::string &body) @@ -641,3 +655,38 @@ bool Principal::get_bool_from_xml(xmlNodePtr nodo) return tmp == "true"; } +void Principal::on_mnu_property() +{ + dlg_property->show(); +} + +void Principal::on_dlg_property_ok() +{ + if (conexion) { + PlaQui::Server::Command c("plant", "set_frequency"); + c.add_arg("default"); + c.add_arg( dlg_property->get_velocity() ); + + conexion->send(c); + } + dlg_property->hide(); +} + +void Principal::on_btn_simulate_clicked() +{ + if (conexion == NULL) return; + + PlaQui::Server::Command c("plant", "start"); + c.add_arg("default"); + conexion->send(c); +} + +void Principal::on_btn_pause_clicked() +{ + if (conexion == NULL) return; + + PlaQui::Server::Command c("plant", "stop"); + c.add_arg("default"); + conexion->send(c); +} + -- 2.43.0