4 int WorkPlace::pointed = -1;
6 WorkPlace::WorkPlace(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
8 gc = Gdk::GC::create(get_window());
9 std::cout << "Aca" << std::endl;
10 Glib::RefPtr<Gdk::Colormap> colormap = gc->get_colormap();
11 color_in = Gdk::Color("red");
12 color_out = Gdk::Color("blue");
13 color_dot = Gdk::Color("black");
14 colormap->alloc_color(color_in);
15 colormap->alloc_color(color_out);
16 colormap->alloc_color(color_dot);
19 WorkPlace::~WorkPlace()
23 void WorkPlace::on_realize()
25 Gtk::Fixed::on_realize();
26 gc = Gdk::GC::create(get_window());
27 std::cout << "Aca" << std::endl;
28 Glib::RefPtr<Gdk::Colormap> colormap = gc->get_colormap();
29 color_in = Gdk::Color("red");
30 color_out = Gdk::Color("blue");
31 colormap->alloc_color(color_in);
32 colormap->alloc_color(color_out);
35 bool WorkPlace::on_expose_event(GdkEventExpose *event)
38 gc->set_foreground(color_dot);
39 for(x=0; x<get_width(); x+=32)
40 for (y=0; y<get_height();y+=32){
41 get_window()->draw_point (gc, x,y);
42 get_window()->draw_point (gc, x,y+1);
43 get_window()->draw_point (gc, x,y-1);
44 get_window()->draw_point (gc, x+1,y);
45 get_window()->draw_point (gc, x-1,y);
49 std::list<CItem *>::iterator j = listaItems->begin();
50 while ( j != listaItems->end() ) {
51 (*j)->update_logic_position();
56 int a, b, w, z, x_offset, y_offset, img;
57 std::list<t_line>::iterator i = lista_lineas_in.begin();
58 while ( i != lista_lineas_in.end() ) {
60 if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) {
61 img = get_logic_item(temp.logic_id)->get_img_actual();
62 x_offset = y_offset = 0;
76 get_logic_item(temp.logic_id)->get_out_logic_connect_position(a, b);
77 get_item(temp.store_id)->get_in_logic_connect_position(w,z);
78 draw_line(a+x_offset, b+y_offset, w,z, color_in);
79 get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset);
83 i = lista_lineas_out.begin();
84 while ( i != lista_lineas_out.end() ) {
86 if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) {
87 img = get_logic_item(temp.logic_id)->get_img_actual();
88 x_offset = y_offset = 0;
102 get_item(temp.store_id)->get_out_logic_connect_position(w,z);
103 get_logic_item(temp.logic_id)->get_in_logic_connect_position(a, b);
104 // draw_line(w, z, a, b, color_out);
105 draw_line(w, z, a+x_offset, b+y_offset,color_out);
106 get_window()->draw_line(gc, a, b, a+x_offset, b+y_offset);
113 void WorkPlace::delete_item(int _id)
116 CItem::logic_connect = false;
117 std::list<CItem*>::iterator i = listaItems->begin();
118 while ( i != listaItems->end() ){
120 if ( temp->get_id() == _id ){
121 listaItems->erase(i);
127 i = lista_logic_Items->begin();
128 while ( i != lista_logic_Items->end() ){
130 if ( temp->get_id() == _id ){
131 lista_logic_Items->erase(i);
140 CItem* WorkPlace::get_logic_item(int _id)
142 std::list<CItem *>::iterator i = lista_logic_Items->begin();
143 while ( i != lista_logic_Items->end() ){
144 if ( (*i)->get_id() == _id )
151 CItem *WorkPlace::get_item(int _id)
153 std::list<CItem *>::iterator i = listaItems->begin();
154 while ( i != listaItems->end() ){
155 if ( (*i)->get_id() == _id )
163 void WorkPlace::delete_line(int _id)
165 std::list<t_line>::iterator i = lista_lineas_in.begin();
166 while ( i != lista_lineas_in.end() ){
167 if (get_item( (*i).store_id ) != NULL)
168 if ( get_item( (*i).store_id )->get_id() == _id ) {
169 lista_lineas_in.erase(i);
170 i = lista_lineas_in.begin();
175 i = lista_lineas_in.begin();
176 while ( i != lista_lineas_in.end() ){
177 if ( get_logic_item((*i).logic_id) != NULL)
178 if ( get_logic_item((*i).logic_id)->get_id() == _id) {
179 lista_lineas_in.erase(i);
180 i = lista_lineas_in.begin();
185 std::list<t_line>::iterator j = lista_lineas_out.begin();
186 while ( j != lista_lineas_out.end() ){
187 if ( get_item((*j).store_id) != NULL )
188 if ( get_item((*j).store_id)->get_id() == _id ) {
189 lista_lineas_out.erase(j);
190 j = lista_lineas_out.begin();
195 j = lista_lineas_out.begin();
196 while ( j != lista_lineas_out.end() ){
197 if ( get_logic_item((*j).logic_id) != NULL )
198 if ( get_logic_item((*j).logic_id)->get_id() == _id ) {
199 lista_lineas_out.erase(j);
200 j = lista_lineas_out.begin();
206 void WorkPlace::update_logic_position()
208 std::list<CItem*>::iterator i = listaItems->begin();
209 while ( i != listaItems->end() ){
210 (*i)->update_logic_position();
213 i = lista_logic_Items->begin();
214 while ( i != lista_logic_Items->end() ){
215 (*i)->update_logic_position();
220 void WorkPlace::draw_line(int x1, int y1, int x2, int y2, Gdk::Color &color)
222 gc->set_foreground(color);
223 gc->set_line_attributes(3, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER);
224 get_window()->draw_line (gc, x1, y1, x1, y2);
225 get_window()->draw_line (gc, x1, y2, x2, y2);