]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/src/workplace.cpp
-Se arregla lo del id cuando se carga una planta
[z.facultad/75.42/plaqui.git] / Constructor / src / workplace.cpp
1 #include "workplace.h"
2 #include "item.h"
3
4 int WorkPlace::pointed = -1;
5
6 WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
7 {
8 }
9
10 WorkPlace::~WorkPlace()
11 {
12 }
13
14 bool WorkPlace::on_expose_event(GdkEventExpose *event)
15 {
16         int x, y;
17         for(x=0; x<get_width(); x+=32) 
18                 for (y=0; y<get_height();y+=32){
19                         get_window()->draw_point (get_style()->get_black_gc(), x,y);
20                         get_window()->draw_point (get_style()->get_black_gc(), x,y+1);
21                         get_window()->draw_point (get_style()->get_black_gc(), x,y-1);
22                         get_window()->draw_point (get_style()->get_black_gc(), x+1,y);
23                         get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
24                 }
25                 
26         
27         Glib::RefPtr<Gdk::GC> gc = get_style()->get_black_gc();
28         Gdk::Color color;
29         color.set_rgb(255,0,0);
30         gc->set_rgb_bg_color(color);
31         get_style()->set_black(color);
32         int w, z;               
33         std::list<t_line>::iterator i = lista_lineas.begin();
34         while ( i != lista_lineas.end() ) {
35                 t_line temp = *i;
36                 temp.store->get_logic_connect_position(w,z);
37                 get_window()->draw_line (get_style()->get_black_gc(), temp.logic->get_position_x(),temp.logic->get_position_y(), w,z);
38                 i++;
39         }
40         return true;
41 }
42
43 void WorkPlace::delete_item(int _id)
44 {
45         CItem::logic_connect = false;
46         std::list<CItem*>::iterator i = listaItems->begin();
47         while ( i != listaItems->end() ){
48         CItem *temp = *i;
49                 if ( temp->get_id() == _id ){
50                         delete_line(_id);
51                         listaItems->erase(i);
52                         delete temp;
53                         break;
54                 }
55                 i++;
56         }
57         i = lista_logic_Items->begin();
58         while ( i != lista_logic_Items->end() ){
59         CItem *temp = *i;
60                 if ( temp->get_id() == _id ){
61                         delete_line(_id);
62                         lista_logic_Items->erase(i);
63                         delete temp;
64                         break;
65                 }
66                 i++;
67         }
68         
69 }
70
71 CItem* WorkPlace::get_logic_item(int _id)
72 {
73         std::list<CItem *>::iterator i = lista_logic_Items->begin();
74         while ( i != lista_logic_Items->end() ){
75                 CItem *temp = *i;
76                 if ( temp->get_id() == _id ) 
77                         return temp;
78                 i++;
79         }
80         return NULL;
81 }
82
83 void WorkPlace::delete_line(int _id)
84 {
85         std::list<t_line>::iterator i = lista_lineas.begin();
86         while ( i != lista_lineas.end() ){
87                 if ( (*i).store->get_id() == _id ) {
88                         lista_lineas.erase(i);
89                         i = lista_lineas.begin();
90                 }
91                 i++;
92         }
93         i = lista_lineas.begin();
94         while ( i != lista_lineas.end() ){
95                 if ( (*i).logic->get_id() == _id ) {
96                         lista_lineas.erase(i);
97                         i = lista_lineas.begin();
98                 }
99                 i++;
100         }       
101 }