# copyright= 'Huynh Duong Phuong Vi @ 2013'
# suforyou.vn@gmail.com
module S4U     	  
      def self.getmenu ;@s4u_menu ; end
      @s4u_menu=UI.menu("Plugins").add_submenu("Suforyou")  if @s4u_menu==nil
      module S4u_SelecTool        
           Sketchup::require 'sketchup.rb' 
	       Sketchup::require 'langhandler.rb'	
           Sketchup::require "s4u_selectool/s4u_selectool_code" 	    	     
           if(not file_loaded?("s4u_selectool_menu"))                                              
               selectool_tb = UI::Toolbar.new $s4u_selectoolStrings.GetString("s4u-SelecTool")             
                           
              ver_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select vertical edges")) {                
               self.selectedge(90) }
               ver_cmd.large_icon = "edgevertical_large.png"
               ver_cmd.small_icon = "edgevertical_small.png"
               ver_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select vertical edges")
               ver_cmd.tooltip=$s4u_selectoolStrings.GetString("Select vertical edges")
               ver_cmd.menu_text = $s4u_selectoolStrings.GetString("Select vertical edges")
               selectool_tb  =  selectool_tb.add_item  ver_cmd               
               
               hor_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select horizontal edges")) {                
               self.selectedge(0) }
               hor_cmd.large_icon = "edgehorizontal_large.png"
               hor_cmd.small_icon = "edgehorizontal_small.png"
               hor_cmd.status_bar_text= $s4u_selectoolStrings.GetString("Select horizontal edges")
               hor_cmd.tooltip= $s4u_selectoolStrings.GetString("Select horizontal edges")
               hor_cmd.menu_text = $s4u_selectoolStrings.GetString("Select horizontal edges")
               selectool_tb  =  selectool_tb.add_item  hor_cmd                       
              
               slope_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select slope edges")) {                
               self.selectedge(nil) }
               slope_cmd.large_icon = "edgeslope_large.png"
               slope_cmd.small_icon = "edgeslope_small.png"
               slope_cmd.status_bar_text = $s4u_selectoolStrings.GetString( "Edge and xy plane")
               slope_cmd.tooltip = $s4u_selectoolStrings.GetString("Select slope edges")
               slope_cmd.menu_text = $s4u_selectoolStrings.GetString("Select slope edges")
               selectool_tb  =  selectool_tb.add_item  slope_cmd  
               
               samelength_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select same length")) {                
               self.select_same_length }
               samelength_cmd.large_icon = "samelength_large.png"
               samelength_cmd.small_icon = "samelength_small.png"
               samelength_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select 1 edge")
               samelength_cmd.tooltip= $s4u_selectoolStrings.GetString("Select same length")
               samelength_cmd.menu_text = $s4u_selectoolStrings.GetString("Select same length")
                 
               
               length_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select length edge")) {                
               self.select_length }
               length_cmd.large_icon = "edgelength_large.png"
               length_cmd.small_icon = "edgelength_small.png"
               length_cmd.status_bar_text = $s4u_selectoolStrings.GetString( "Select edges by length")
               length_cmd.tooltip= $s4u_selectoolStrings.GetString("Select length edges")
               length_cmd.menu_text= $s4u_selectoolStrings.GetString("Select length edges")
               selectool_tb = selectool_tb.add_item  length_cmd  
               selectool_tb.add_separator 

               submenu=S4U.getmenu
               submenu.add_separator 
               submenu.add_item ver_cmd               
               submenu.add_item hor_cmd 
               submenu.add_item slope_cmd             
               submenu.add_item length_cmd  
	       submenu.add_item samelength_cmd             

               ver_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select vertical faces")) {                
               self.selectface(90) }
               ver_cmd.large_icon = "facevertical_large.png"
               ver_cmd.small_icon = "facevertical_small.png"
               ver_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select vertical faces")
               ver_cmd.tooltip = $s4u_selectoolStrings.GetString("Select vertical faces")
               ver_cmd.menu_text = $s4u_selectoolStrings.GetString("Select vertical faces")
               selectool_tb  =  selectool_tb.add_item  ver_cmd               
               
               hor_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select horizontal faces")) {                
               self.selectface(0) }
               hor_cmd.large_icon = "facehorizontal_large.png"
               hor_cmd.small_icon = "facehorizontal_small.png"
               hor_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select horizontal faces")
               hor_cmd.tooltip = $s4u_selectoolStrings.GetString("Select horizontal faces")
               hor_cmd.menu_text = $s4u_selectoolStrings.GetString("Select horizontal faces")
               selectool_tb  =  selectool_tb.add_item  hor_cmd                       
              
               slope_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select slope faces")) {                
               self.selectface(nil) }
               slope_cmd.large_icon = "faceslope_large.png"
               slope_cmd.small_icon = "faceslope_small.png"
               slope_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Vector normal's face and z axis")
               slope_cmd.tooltip = $s4u_selectoolStrings.GetString("Select slope faces")
               slope_cmd.menu_text = $s4u_selectoolStrings.GetString("Select slope faces")
               selectool_tb  =  selectool_tb.add_item  slope_cmd  
               
               numface_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select numver faces")) {                
               self.selectface_numvers }
               numface_cmd.large_icon = "facenumver_large.png"
               numface_cmd.small_icon = "facenumver_small.png"
               numface_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select face by number vertex")
               numface_cmd.tooltip = $s4u_selectoolStrings.GetString("Select numver faces")
               numface_cmd.menu_text = $s4u_selectoolStrings.GetString("Select numver faces")
               selectool_tb  =  selectool_tb.add_item  numface_cmd 	        
                
               
               face_area_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select area faces")) {                
               self.select_area }
               face_area_cmd.large_icon = "face_area_large.png"
               face_area_cmd.small_icon = "face_area_small.png"
               face_area_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select face by area faces")
               face_area_cmd.tooltip = $s4u_selectoolStrings.GetString("Select area faces")
               face_area_cmd.menu_text = $s4u_selectoolStrings.GetString("Select area faces")
               selectool_tb  =  selectool_tb.add_item  face_area_cmd 
	       
	       same_area_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select same area")) {                
               self.select_same_area }
               same_area_cmd.large_icon = "same_area_large.png"
               same_area_cmd.small_icon = "same_area_small.png"
               same_area_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select 1 face")
               same_area_cmd.tooltip = $s4u_selectoolStrings.GetString("Select same area")
               same_area_cmd.menu_text = $s4u_selectoolStrings.GetString("Select same area")
               
               faceparallel_cmd = UI::Command.new($s4u_selectoolStrings.GetString("Select parallel face")) {                
               self.selectface_parallel }
               faceparallel_cmd.large_icon = "parallel_face_large.png"
               faceparallel_cmd.small_icon = "parallel_face_small.png"
               faceparallel_cmd.status_bar_text = $s4u_selectoolStrings.GetString("Select 1 face")
               faceparallel_cmd.tooltip  = $s4u_selectoolStrings.GetString("Select parallel face")
               faceparallel_cmd.menu_text = $s4u_selectoolStrings.GetString("Select parallel face")
               
               selectool_tb.add_separator
               selectool_tb  =  selectool_tb.add_item  samelength_cmd
               selectool_tb  =  selectool_tb.add_item  same_area_cmd
	           selectool_tb  =  selectool_tb.add_item  faceparallel_cmd
               submenu.add_item ver_cmd               
               submenu.add_item hor_cmd 
               submenu.add_item slope_cmd 
               submenu.add_item numface_cmd 
               submenu.add_item face_area_cmd       
               submenu.add_item same_area_cmd
               submenu.add_item faceparallel_cmd
               selectool_tb.show  
          end
          file_loaded("s4u_selectool_menu")
      end
end
