4 Not::Not(int orientacion)
7 in_connected = out_connected = false;
8 imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/not_n.png");
9 imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/not_s.png");
10 imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/not_e.png");
11 imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/not_o.png");
12 null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
13 imgActual = orientacion;
44 set_size_request(image->get_width(), image->get_height());
52 bool Not::on_button_press_event(GdkEventButton *event)
54 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
55 WorkPlace::pointed = ID;
57 if (CItem::logic_connect) {
58 if (CItem::gate_id != -1) {
59 if ( detect_click_position((int)event->x, (int)event->y) == IN && !in_connected && !workplace->get_logic_item(CItem::gate_id)->get_out_logic_connect()) {
60 tmp_line.logic_id = CItem::gate_id;
61 workplace->get_logic_item(CItem::gate_id)->set_out_connected(true);
62 set_in_connected(true);
63 tmp_line.store_id = ID;
64 workplace->lista_lineas_logic.push_back(tmp_line);
65 workplace->queue_draw();
70 if ( detect_click_position((int)event->x, (int)event->y ) == OUT && !out_connected ) {
73 if ( detect_click_position((int)event->x, (int)event->y ) == IN && !in_connected) {
77 list_pointed->push_back(name);
78 combo_entry->set_popdown_strings(*list_pointed);
79 combo_entry->get_entry()->set_text (name);
80 workplace->queue_draw();
83 sprintf(f," Conector OUT = %d Conector IN = %d",out_connected, in_connected);
85 status_bar->push ( text, 0);
88 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
90 image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
122 set_size_request(image->get_width(),image->get_height());
123 image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
125 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
126 menu_popup.popup(event->button, event->time);
127 return true; //It has been handled.
129 workplace->queue_draw();
132 void Not::on_menu_popup_rotar()
134 GdkEventButton event;
135 event.type = GDK_BUTTON_PRESS;
137 Not::on_button_press_event(&event);
140 void Not::save(FILE *archivo)
142 vec_connector.clear();
145 char c_img[50], c_x[50], c_y[50], c_id[50];
146 sprintf(c_id,"%d",ID);
147 sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
148 sprintf(c_x,"\t\t<x>%d</x>\n",x);
149 sprintf(c_y,"\t\t<y>%d</y>\n",y);
150 dato = "\t<not nombre=\""+name+"\" id=\"";
156 for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
157 if ( vec_connector[i].type == IN ) {
158 if ( vec_connector[i].cistern_connector == 1 ) {
159 dato += "\t\t<entrada id = \"superior\">";
160 dato += vec_connector[i].name_dest + "</entrada>\n";
162 if ( vec_connector[i].cistern_connector == 0 ) {
163 dato += "\t\t<entrada id = \"inferior\">";
164 dato += vec_connector[i].name_dest + "</entrada>\n";
166 if ( vec_connector[i].cistern_connector == -1 ) {
167 dato += "\t\t<entrada>";
168 dato += vec_connector[i].name_dest + "</entrada>\n";
171 dato += "\t\t<salida>";
172 dato += vec_connector[i].name_dest + "</salida>\n";
175 dato += "\t</not>\n";
176 fprintf(archivo, dato.c_str() );
179 bool Not::check_connection()
181 int cant_in = 0, cant_out =0;
182 t_logic_connector temp;
183 std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
184 while ( i != workplace->lista_lineas_in.end() ) {
185 if ( (*i).logic_id == ID ) {
187 temp.name_dest = workplace->get_item((*i).store_id)->get_name();
188 vec_connector.push_back(temp);
194 i = workplace->lista_lineas_out.begin();
195 while ( i != workplace->lista_lineas_out.end() ) {
196 if ( (*i).logic_id == ID ) {
198 temp.name_dest = workplace->get_item((*i).store_id)->get_name();
199 if ( dynamic_cast<Cistern *>(workplace->get_item((*i).store_id)) ) {
200 if ( (*i).cistern_out1 )
201 temp.cistern_connector = 1; //arriba
203 temp.cistern_connector = 0; //abajo
205 temp.cistern_connector = -1; //si no es tanque.
206 vec_connector.push_back(temp);
212 i = workplace->lista_lineas_logic.begin();
213 while ( i != workplace->lista_lineas_logic.end() ) {
214 if ( (*i).logic_id == ID ) {
216 temp.name_dest = workplace->get_logic_item((*i).store_id)->get_name();
217 vec_connector.push_back(temp);
223 i = workplace->lista_lineas_logic.begin();
224 while ( i != workplace->lista_lineas_logic.end() ) {
225 if ( (*i).store_id == ID ) {
227 temp.name_dest = workplace->get_logic_item((*i).logic_id)->get_name();
228 vec_connector.push_back(temp);
237 ConnectorType Not::detect_click_position(int _a, int _b)
241 if ( (_a<=32 )&&(_a>=22)&&(_b<=20)&&(_b>=10) )
243 if ( (_a<=10)&&(_a>=0)&&(_b<=20)&&(_b>=10) )
247 if ( (_a<=20 )&&(_a>=10)&&(_b<=32)&&(_b>=22) )
249 if ( (_a<=20)&&(_a>=10)&&(_b<=10)&&(_b>=0) )
253 if ( (_a<=10 )&&(_a>=0)&&(_b<=20)&&(_b>=10) )
255 if ( (_a<=32)&&(_a>=22)&&(_b<=20)&&(_b>=10) )
259 if ( (_a<=20 )&&(_a>=10)&&(_b<=10)&&(_b>=0) )
261 if ( (_a<=20)&&(_a>=10)&&(_b<=32)&&(_b>=22) )
267 void Not::update_logic_position()
296 void Not::get_in_logic_connect_position(int& _a, int& _b)
302 void Not::get_out_logic_connect_position(int& _a, int& _b)
308 void Not::set_out_connected(bool _o)
313 void Not::set_in_connected(bool _o)
318 bool Not::get_out_logic_connect()
320 return out_connected;
323 bool Not::get_in_logic_connect()
328 void Not::draw_connectors()
330 Glib::RefPtr<Gdk::Window> window = get_window();
357 gc->set_foreground(red);
358 gc->set_background(red);
359 window->draw_rectangle(gc, 1, a, b, 10, 10);
360 gc->set_foreground(blue);
361 gc->set_background(blue);
362 window->draw_rectangle(gc, 1, c, d, 10, 10);