-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcontroller.py
207 lines (159 loc) · 5.85 KB
/
controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import StackActions
from view import ui
import copy
from model import graph
class Controller:
def __init__(self):
self.__view = ui.Ui()
self.__view.connect_signals(self)
self.__undo_stack = StackActions.StackActions()
self.__redo_stack = StackActions.StackActions()
self.__papelera = []
self.__copy_o_paste = 1
self.__tmp = 0
self.__areaSel = False
def throw_app(self):
self.__view.throw_ui()
self.__redo_stack.push(self.__view.get_draw_graph())
def on_close(self,widget,data=None):
self.__view.stop_ui()
def on_cursor(self, widget,data=None): #Accede al Cursor
self.__view.change_operation(2)
self.__areaSel = False
def on_node(self,widget,data=None): #Accede a Crear el Nodo
self.__view.change_operation(1)
self.__areaSel = False
def on_add_edge(self, widget, data=None): #Accede a Crear el Arco
self.__view.change_operation(3)
self.__areaSel = False
def on_select(self, widget, data=None): #Accede a Seleccion
self.__view.change_operation(4)
self.__areaSel = False
def on_to_pdf(self, widget, data=None):
self.__view.show_window_export()
def on_print(self, widget, data=None):
self.__view.show_print()
def on_export_clicked(self, widget, data=None):
self.__view.to_pdf()
def on_destroyloader(self, widget, data=None):
self.__view.destroy_export()
def on_clicked(self, widget, data=None):
self.option_clicked(data)
def motion_clicked(self, widget, data=None):
self.option_moved(data)
def on_click_released(self, widget, data=None):
self.option_released(data)
def on_redo(self,widget,data=None):
tmp = self.__redo_stack.pop()
print "deshaciendo en redo con grafo igual a ",tmp
if tmp is not None:
self.__undo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_draw_graph(copy.deepcopy(tmp))
def on_undo(self, widget, data=None):
tmp = self.__undo_stack.pop()
if tmp is not None:
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_draw_graph(copy.deepcopy(tmp))
#FUNCIONES PASADAS DESDE LA VISTA
def option_clicked(self, data = None):
if self.__view.get_draw_status() == 1:
if data.button == 1:
self.__redo_stack.push(self.__view.get_draw_graph())
self.__view.insert_new_node(data)
if self.__view.get_draw_status() == 2:
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
if self.__view.get_draw_status() == 3:
if data.button == 1:
if self.__tmp == 0:
self.__view.insert_edge(data)
self.__tmp += 1
else:
self.__redo_stack.push(self.__view.get_draw_graph())
self.__view.insert_edge(data)
self.__tmp = 0
if self.__view.get_draw_status() == 4:
if data.button == 1:
if self.__areaSel == False:
self.__view.set_data()
self.__view.select_area(data)
if data.button == 3:
self.__view.reset()
self.__areaSel = False
if data.button == 3:
if self.__view.get_draw_over(data) == 1:
self.__view.call_popup(data, 1)
if self.__view.get_draw_over(data) == 2:
self.__view.call_popup(data, 2)
if self.__view.get_draw_over(data) == 3:
self.__view.call_popup(data, 3)
def option_moved(self, data = None):
if self.__view.get_draw_status() == 1:
return True
if self.__view.get_draw_status() == 2:
self.__view.move_node(data)
if self.__view.get_draw_status() == 3:
return True
if self.__view.get_draw_status() == 4:
if self.__areaSel == True:
self.__view.move_selected(data)
else:
self.__view.set_data()
def option_released(self, data = None):
if self.__view.get_draw_status() == 1:
return True
if self.__view.get_draw_status() == 2:
return True
if self.__view.get_draw_status() == 3:
return True
if self.__view.get_draw_status() == 4:
if data.button == 1:
if self.__view.get_draw_ind() == 2:
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__areaSel = self.__view.select_area_end()
def show_label(self, widget, data = None):
self.__view.show_label()
def set_label(self, widget, data = None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_new_label()
def show_color(self, widget, data = None):
self.__view.show_color()
def set_color(self, widget, data = None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_new_color()
def del_nodo(self, widget, data = None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.del_nodo()
def del_edge(self, widget, data = None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.del_edge()
def show_malla(self, widget, data=None):
self.__view.set_malla(widget.get_active())
def show_coordenates(self, widget, data=None):
self.__view.show_coordenates()
def set_coordenates(self, widget, data=None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_coordenates()
def show_tamanio(self, widget, data=None):
self.__view.show_tamanio()
def set_tamanio(self, widget, data=None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_tamanio()
def show_forma_nodo(self, widget, data=None):
self.__view.show_forma_nodo()
def set_forma_nodo(self, widget, data=None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_forma_nodo()
def show_forma_arista(self, widget, data=None):
self.__view.show_forma_arista()
def set_forma_arista(self, widget, data=None):
self.__redo_stack.push(copy.deepcopy(self.__view.get_draw_graph()))
self.__view.set_forma_arista()
def copy_selected(self, widget, data=None):
self.__papelera = self.__view.copy_selected()
self.__copy_o_paste = 1
def paste_selected(self, widget, data=None):
self.__view.paste_selected(self.__papelera, self.__copy_o_paste)
if self.__copy_o_paste == 2:
del self.__papelera[:]
a = Controller()
a.throw_app()