# 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_toComponents          
           Sketchup::require 'sketchup.rb'     
           Sketchup::require "s4u_tocomponents/s4u_tocomponents_code"
           if(not file_loaded?("s4u_tocomponents_menu"))                                              
               toComponents_tb = UI::Toolbar.new ($s4u_toComponentsStrings.GetString("s4u-to Components"))
                
               
               dl2c_cmd = UI::Command.new ($s4u_toComponentsStrings.GetString("Draw Lines to Components")) { 
	 	Sketchup::require "s4u_tocomponents/s4u_drawlinetocom_code"                
	 	Sketchup.active_model.select_tool  S4U::S4u_toComponents::DrawLinetoComponent.new }
               dl2c_cmd.large_icon = "drawlines2coms_large.png"
               dl2c_cmd.small_icon = "drawlines2coms_small.png"
               dl2c_cmd.status_bar_text = $s4u_toComponentsStrings.GetString("Select 1 Face or 1 Component")
               dl2c_cmd.tooltip = $s4u_toComponentsStrings.GetString("Draw Lines to Components")
               dl2c_cmd.menu_text = $s4u_toComponentsStrings.GetString("Draw Lines to Components")
               toComponents_tb =  toComponents_tb.add_item dl2c_cmd   
               
               l2c_cmd = UI::Command.new ($s4u_toComponentsStrings.GetString("Lines to Components")) { S4u_toComponents.linestocoms }
               l2c_cmd.large_icon = "lines2coms_large.png"
               l2c_cmd.small_icon = "lines2coms_small.png"
               l2c_cmd.status_bar_text = $s4u_toComponentsStrings.GetString("Select 1 Face(or 1 component) and Lines")
               l2c_cmd.tooltip = $s4u_toComponentsStrings.GetString("Lines to Components")
               l2c_cmd.menu_text = $s4u_toComponentsStrings.GetString("Lines to Components")
               toComponents_tb =  toComponents_tb.add_item l2c_cmd    
                         
               f2c_cmd = UI::Command.new($s4u_toComponentsStrings.GetString("Faces to Components")) { S4u_toComponents.facestocoms(0) }
               f2c_cmd.large_icon = "faces2coms_large.png"
               f2c_cmd.small_icon = "faces2coms_small.png"
               f2c_cmd.status_bar_text = $s4u_toComponentsStrings.GetString("Select 1 Component and Faces")
               f2c_cmd.tooltip = $s4u_toComponentsStrings.GetString("Faces to Components")
               f2c_cmd.menu_text = $s4u_toComponentsStrings.GetString("Faces to Components")
               toComponents_tb =  toComponents_tb.add_item f2c_cmd  

               f2c1_cmd = UI::Command.new($s4u_toComponentsStrings.GetString("Faces to Components(arrange)")) { S4u_toComponents.facestocoms(1) }
               f2c1_cmd.large_icon = "faces2coms1_large.png"
               f2c1_cmd.small_icon = "faces2coms1_small.png"
               f2c1_cmd.status_bar_text = $s4u_toComponentsStrings.GetString("Select 1 Component and Faces(arrange)")
               f2c1_cmd.tooltip = $s4u_toComponentsStrings.GetString("Faces to Components(arrange)")
               f2c1_cmd.menu_text = $s4u_toComponentsStrings.GetString("Faces to Components(arrange)")
               toComponents_tb =  toComponents_tb.add_item f2c1_cmd  
  
               g2c_cmd = UI::Command.new($s4u_toComponentsStrings.GetString("Groups to Components")) { S4u_toComponents.groupstocoms }
               g2c_cmd.large_icon = "groups2coms_large.png"
               g2c_cmd.small_icon = "groups2coms_small.png"
               g2c_cmd.status_bar_text = $s4u_toComponentsStrings.GetString("Select 1 Component and Groups")
               g2c_cmd.tooltip = "Groups to Components"
               g2c_cmd.menu_text = $s4u_toComponentsStrings.GetString("Groups to Components")
               toComponents_tb =  toComponents_tb.add_item g2c_cmd  
              
               submenu=S4U.getmenu
	       submenu.add_separator
               submenu.add_item dl2c_cmd 
               submenu.add_item l2c_cmd                
               submenu.add_item f2c_cmd  
	       submenu.add_item f2c1_cmd              
               submenu.add_item g2c_cmd 
               toComponents_tb.show  
          end
          file_loaded("s4u_tocomponents_menu")
      end
end
