6 int WorkPlace::pointed = -1;
8 WorkPlace::WorkPlace(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
10 gc = Gdk::GC::create(get_window());
11 std::cout << "Aca" << std::endl;
12 Glib::RefPtr<Gdk::Colormap> colormap = gc->get_colormap();
13 color_in = Gdk::Color("red");
14 color_out = Gdk::Color("blue");
15 color_dot = Gdk::Color("black");
16 colormap->alloc_color(color_in);
17 colormap->alloc_color(color_out);
18 colormap->alloc_color(color_dot);
21 WorkPlace::~WorkPlace()
25 void WorkPlace::on_realize()
27 Gtk::Fixed::on_realize();
28 gc = Gdk::GC::create(get_window());
29 std::cout << "Aca" << std::endl;
30 Glib::RefPtr<Gdk::Colormap> colormap = gc->get_colormap();
31 color_in = Gdk::Color("red");
32 color_out = Gdk::Color("blue");
33 colormap->alloc_color(color_in);
34 colormap->alloc_color(color_out);
37 bool WorkPlace::on_expose_event(GdkEventExpose *event)
40 gc->set_foreground(color_dot);
41 for(x=0; x<get_width(); x+=32)
42 for (y=0; y<get_height();y+=32){
43 get_window()->draw_point (gc, x,y);
44 get_window()->draw_point (gc, x,y+1);
45 get_window()->draw_point (gc, x,y-1);
46 get_window()->draw_point (gc, x+1,y);
47 get_window()->draw_point (gc, x-1,y);
51 std::list<CItem *>::iterator j = listaItems->begin();
52 while ( j != listaItems->end() ) {
53 (*j)->update_logic_position();
58 int a, b, w, z, x_offset, y_offset, img;
59 int item_x_offset, item_y_offset;
60 std::list<t_line>::iterator i = lista_lineas_in.begin();
61 while ( i != lista_lineas_in.end() ) {
63 if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) {
64 img = get_logic_item(temp.logic_id)->get_img_actual();
65 item_y_offset = item_x_offset = 0;
66 x_offset = y_offset = 0;
67 if (dynamic_cast<Pump *>(get_item(temp.store_id))) {
69 } else if (dynamic_cast<Exclusa *>(get_item(temp.store_id))) {
70 if (get_item(temp.store_id)->get_img_actual()==0) {
89 get_logic_item(temp.logic_id)->get_out_logic_connect_position(a, b);
90 get_item(temp.store_id)->get_in_logic_connect_position(w,z);
91 draw_line(a+x_offset, b+y_offset, w+item_x_offset, z+item_y_offset, color_in);
92 get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset);
93 get_window()->draw_line(gc, w, z, w+item_x_offset, z+item_y_offset);
97 i = lista_lineas_out.begin();
98 while ( i != lista_lineas_out.end() ) {
100 if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) {
101 img = get_logic_item(temp.logic_id)->get_img_actual();
102 item_y_offset = item_x_offset = 0;
103 x_offset = y_offset = 0;
117 get_item(temp.store_id)->get_out_logic_connect_position(w,z);
118 get_logic_item(temp.logic_id)->get_in_logic_connect_position(a, b);
119 draw_line(w+item_y_offset, z+item_y_offset, a+x_offset, b+y_offset,color_out);
120 get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset);
127 void WorkPlace::delete_item(int _id)
130 CItem::logic_connect = false;
131 std::list<CItem*>::iterator i = listaItems->begin();
132 while ( i != listaItems->end() ){
134 if ( temp->get_id() == _id ){
135 listaItems->erase(i);
141 i = lista_logic_Items->begin();
142 while ( i != lista_logic_Items->end() ){
144 if ( temp->get_id() == _id ){
145 lista_logic_Items->erase(i);
154 CItem* WorkPlace::get_logic_item(int _id)
156 std::list<CItem *>::iterator i = lista_logic_Items->begin();
157 while ( i != lista_logic_Items->end() ){
158 if ( (*i)->get_id() == _id )
165 CItem *WorkPlace::get_item(int _id)
167 std::list<CItem *>::iterator i = listaItems->begin();
168 while ( i != listaItems->end() ){
169 if ( (*i)->get_id() == _id )
177 void WorkPlace::delete_line(int _id)
179 std::list<t_line>::iterator i = lista_lineas_in.begin();
180 while ( i != lista_lineas_in.end() ){
181 if (get_item( (*i).store_id ) != NULL)
182 if ( get_item( (*i).store_id )->get_id() == _id ) {
183 lista_lineas_in.erase(i);
184 i = lista_lineas_in.begin();
189 i = lista_lineas_in.begin();
190 while ( i != lista_lineas_in.end() ){
191 if ( get_logic_item((*i).logic_id) != NULL)
192 if ( get_logic_item((*i).logic_id)->get_id() == _id) {
193 lista_lineas_in.erase(i);
194 i = lista_lineas_in.begin();
199 std::list<t_line>::iterator j = lista_lineas_out.begin();
200 while ( j != lista_lineas_out.end() ){
201 if ( get_item((*j).store_id) != NULL )
202 if ( get_item((*j).store_id)->get_id() == _id ) {
203 lista_lineas_out.erase(j);
204 j = lista_lineas_out.begin();
209 j = lista_lineas_out.begin();
210 while ( j != lista_lineas_out.end() ){
211 if ( get_logic_item((*j).logic_id) != NULL )
212 if ( get_logic_item((*j).logic_id)->get_id() == _id ) {
213 lista_lineas_out.erase(j);
214 j = lista_lineas_out.begin();
220 void WorkPlace::update_logic_position()
222 std::list<CItem*>::iterator i = listaItems->begin();
223 while ( i != listaItems->end() ){
224 (*i)->update_logic_position();
227 i = lista_logic_Items->begin();
228 while ( i != lista_logic_Items->end() ){
229 (*i)->update_logic_position();
234 void WorkPlace::draw_line(int x1, int y1, int x2, int y2, Gdk::Color &color)
236 gc->set_foreground(color);
237 gc->set_line_attributes(3, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER);
238 get_window()->draw_line (gc, x1, y1, x1, y2);
239 get_window()->draw_line (gc, x1, y2, x2, y2);