var _SELECTED_OBJECT=null;var _SELECTED_STRAIGHT=null;var _LIST_OF_POINTS=new Array();var _LINE_PATH=null;var _LINE_PATH_ISLAND=null;var _POLYGON_INTERIOR_RING=null;var _TEXT_DOMAIN="";var _LIST_OF_LINES=new Array();var _LIST_OF_CIRCLES=new Array();var _LIST_OF_SELECTED_OBJECTS=new Array();var _SELECTED_VERTEX=null;var _SELECTED_LINE=null;var _LIST_OF_OPERATIONS=new Array();var _ID_GEOMETRY=-1;function configure_line_path_object(){var a=null;if(_LINE_PATH_ISLAND!=null){a=_LINE_PATH_ISLAND}else{if(_POLYGON_INTERIOR_RING!=null){a=_POLYGON_INTERIOR_RING}else{if(_SELECTED_LINE!=null){a=_SELECTED_LINE}else{if(_LINE_PATH==null){_LINE_PATH=new Line_Path();_LINE_PATH._optimized_drawing=false;_LIST_OF_EXTRA_GRAPHICS.push(_LINE_PATH)}a=_LINE_PATH}}}return a}function clear_points(a){for(var b=0;b<_LIST_OF_POINTS.length;b++){_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",_LIST_OF_POINTS[b]);remove_from_extra_graphics(_LIST_OF_POINTS[b],a)}remove_from_extra_graphics(_SELECTED_VERTEX,a);_SELECTED_VERTEX=null;_LIST_OF_POINTS.splice(0,_LIST_OF_POINTS.length)}function clear_linepath(a){if(_LINE_PATH!=null){remove_from_extra_graphics(_LINE_PATH,a);_LINE_PATH.clear();_LINE_PATH=null}if(_LINE_PATH_ISLAND!=null){remove_from_extra_graphics(_LINE_PATH_ISLAND,a);_LINE_PATH_ISLAND.clear();_LINE_PATH_ISLAND=null}if(_POLYGON_INTERIOR_RING!=null){remove_from_extra_graphics(_POLYGON_INTERIOR_RING,a);_POLYGON_INTERIOR_RING.clear();_POLYGON_INTERIOR_RING=null}_SELECTED_LINE=null}function clear_lines(a){for(var b=0;b<_LIST_OF_LINES.length;b++){remove_from_extra_graphics(_LIST_OF_LINES[b],a)}_LIST_OF_LINES.splice(0,_LIST_OF_LINES.length)}function clear_circles(a){for(var b=0;b<_LIST_OF_CIRCLES.length;b++){remove_from_extra_graphics(_LIST_OF_CIRCLES[b],a)}_LIST_OF_CIRCLES.splice(0,_LIST_OF_CIRCLES.length)}function evt_but_add_ring(){try{if(_LIST_OF_SELECTED_OBJECTS.length!=1||_LIST_OF_SELECTED_OBJECTS[0] instanceof Point||_SELECTED_LINE==null){alert(_MSG_SELECT_OBJECT);return}if(_LIST_OF_SELECTED_OBJECTS[0]._type=="MULTICURVE"){alert("Aggiunta anelli interiori possibili solo a poligoni!");return}if(_POLYGON_INTERIOR_RING==null){_POLYGON_INTERIOR_RING=new Line_Path();_SELECTED_LINE.add_graphics(_POLYGON_INTERIOR_RING)}generic_gis_toolbar_select_button("toolbar_draw_line");document.getElementById(_MAP_ID).style.cursor="crosshair";register_mouse_down_handler(evt_draw_line);change_system_status(new Evt_Draw_Line());alert("È ora possibile aggiungere anelli alla geometria selezionata!")}catch(a){alert("Vector_Graphics_Events_Manager.evt_but_add_ring(): "+a)}}function evt_but_add_island(){try{if(_LIST_OF_SELECTED_OBJECTS.length!=1||_LIST_OF_SELECTED_OBJECTS[0].constructor==Point){alert(_MSG_SELECT_OBJECT);return}if(_LINE_PATH_ISLAND==null){_LINE_PATH_ISLAND=new Line_Path();_LIST_OF_EXTRA_GRAPHICS.push(_LINE_PATH_ISLAND)}generic_gis_toolbar_select_button("toolbar_draw_line");document.getElementById(_MAP_ID).style.cursor="crosshair";register_mouse_down_handler(evt_draw_line);change_system_status(new Evt_Draw_Line());alert("È ora possibile aggiungere geometrie alla geometria selezionata!")}catch(a){alert("Vector_Graphics_Events_Manager.evt_but_add_island(): "+a)}}function evt_but_draw_polar_line(c,b){try{var g=configure_line_path_object();if(g._list_of_graphics.length==0){if(_LIST_OF_POINTS.length!=3){alert(_MSG_SET_3_POINTS);return}else{if(_LIST_OF_POINTS[0].equals(_LIST_OF_POINTS[1])){alert("Primo e secondo Punto non possono essere uguali!");return}}g._direction_vector=new Point(_LIST_OF_POINTS[1]._x-_LIST_OF_POINTS[0]._x,_LIST_OF_POINTS[1]._y-_LIST_OF_POINTS[0]._y);g._start_point=_LIST_OF_POINTS[2].clone();clear_points(_SELECTION_DRAWING_ENGINE)}else{var d=g.get_last_object();if(d.constructor==Circle){alert("Impossibile continuare il disegno da un Cerchio!");return}g._direction_vector=d.compute_direction_vector();if(d.constructor==Arc){g._start_point=d._p3.clone()}else{if(d.constructor==Line){g._start_point=d._p2.clone()}}}var a=Math.sqrt(Math.pow(g._direction_vector._x,2)+Math.pow(g._direction_vector._y,2));var k=new Array(g._direction_vector._x/a,g._direction_vector._y/a);if(c!=""){var f=c*(2*Math.PI/360)*-1;var n=Math.cos(f)*k[0]+(-Math.sin(f)*k[1]);var m=Math.sin(f)*k[0]+Math.cos(f)*k[1];k[0]=n;k[1]=m}k[0]*=b;k[1]*=b;var j=g._start_point._x+k[0];var i=g._start_point._y+k[1];var l=new Point(j,i);var o=new Line(g._start_point,l);o._optimized_drawing=false;g._direction_vector=o.compute_direction_vector();g._start_point=l;g.add_graphics(o);_LIST_OF_POINTS[0]=l;_GENERIC_GIS_UTILS.log_draw_operation("polar_line_draw_line",l);clear_extra_graphics(_ALL_DRAWING_ENGINES);draw_extra_graphics_object(false,l,_EVENTS_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE)}catch(h){alert("Vector_Graphics_Events_Manager.evt_but_draw_polar_line(): "+h)}}function evt_but_polar_line_remove_last(a){var c=configure_line_path_object();if(c._list_of_graphics.length==0){alert(_MSG_OBJECT_REMOVE);return}var b=c._list_of_graphics.pop();if(a){_GENERIC_GIS_UTILS.log_draw_operation("polar_line_remove_last",b)}clear_points(_EVENTS_DRAWING_ENGINE);clear_extra_graphics(_ALL_DRAWING_ENGINES);if(c._list_of_graphics.length>0){_LIST_OF_POINTS[0]=b._p1.clone();draw_extra_graphics_object(false,_LIST_OF_POINTS[0],_EVENTS_DRAWING_ENGINE)}draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE)}function evt_draw_point(a){process_mouse_down(a,_OP_USER)}function evt_draw_line(a){process_mouse_down(a,_OP_USER)}function evt_add_vertex(a){process_mouse_down(a,_OP_USER)}function evt_add_arc(a){process_mouse_down(a,_OP_USER)}function evt_move_vertex(a){process_mouse_down(a,_OP_USER)}function evt_select_vertex(a){process_mouse_down(a,new Evt_Select_Vertex())}function evt_delete_vertex(a){process_mouse_down(a,new Evt_Delete_Vertex())}function evt_remove_ring(a){if(_LIST_OF_SELECTED_OBJECTS.length!=1||_LIST_OF_SELECTED_OBJECTS[0] instanceof Point){_OP_USER=new Idle();alert(_MSG_SELECT_OBJECT);return}if(_LIST_OF_SELECTED_OBJECTS[0]._type=="MULTICURVE"){_OP_USER=new Idle();alert("Rimozione anelli possibile solo a poligoni!");return}process_mouse_down(a,new Evt_Remove_Ring())}function evt_remove_island(a){if(_LIST_OF_SELECTED_OBJECTS.length!=1||_LIST_OF_SELECTED_OBJECTS[0].constructor==Point){_OP_USER=new Idle();alert(_MSG_SELECT_OBJECT);return}process_mouse_down(a,new Evt_Remove_Island())}function evt_select_text(a){process_mouse_down(a,new Evt_Select_Interlis_Text())}function evt_show_attributes_text(a){var b=new Evt_Select_Interlis_Text();b.add_listener(new Listener_Show_Text_Attributes());process_mouse_down(a,b)}function evt_select_segment(a){if(!_MAP_WRAPPER.check_is_layer_selected()){return}process_mouse_down(a,new Evt_Select_Segment())}function evt_select_polygon_segment(a){if(!_MAP_WRAPPER.check_is_layer_selected()){return}process_mouse_down(a,new Evt_Select_Polygon_Segment())}function evt_move_straight_line(a){if(_LIST_OF_LINES.length<1){alert(_MSG_ONE_LINE_REQUIRED);return}process_mouse_down(a,new Evt_Move_Straight_Line())}function evt_remove_straight_line(a){process_mouse_down(a,new Evt_Remove_Straight_Line())}function evt_draw_circle(a){var b=new Evt_Draw_Circle();process_mouse_down(a,b)}function evt_draw_new_circle(a){if(_LIST_OF_POINTS.length<1){alert(_MSG_ONE_POINT_REQUIRED);return}process_mouse_down(a,new Evt_Draw_New_Circle())}function evt_remove_circle(a){process_mouse_down(a,new Evt_Remove_Circle())}function evt_move_feature(a){process_mouse_down(a,new Evt_Move_Feature())};
