proc InitializeGlobalHotKeys {} {
# This has now moved to the resource files
}

#################### Blocking stuff #########################

proc HotKey_CreateBlocksVerts {} {
     ::AIEnv::GUIManagement::InvokeUserActions {
	 {tab "Blocking"}
	 {dez createBlockDEZ}
	 {exclusiveGroupIcon createBlk createBlkVertices}
     }
}

proc HotKey_InitializeBlocks {} {
     ::AIEnv::GUIManagement::InvokeUserActions {
	 {tab "Blocking"}
	 {dez createBlockDEZ}
	 {exclusiveGroupIcon createBlk createBlkIni}
     }
}


proc HotKey_DeleteBlocksPerm {} {
    set ::vid_options(DelBlkPerFlag) 1
    if [ic_hex_blocking_loaded] {	
        ::AIEnv::GUIManagement::InvokeUserActions {
    		{tab "Blocking"}
		{dez deleteBlockDEZ}
        }
    } else {mess "The 'Delete Blocks Permanently' hotkey is only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_DeleteBlocks {} {
    set ::vid_options(DelBlkPerFlag) 0
    if [ic_hex_blocking_loaded] {
        ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez deleteBlockDEZ}
        }
    } else {mess "The 'Delete Blocks' hotkey is only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_ChangeBlockIJK {} {
    if [ic_hex_blocking_loaded] {
        ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editBlockMenuDEZ}
		{exclusiveGroupIcon editBlkmain editBlockIJK}
        }
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_SetEdgeLength {} {
    if [ic_hex_blocking_loaded] {
        ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez moveBVertexDEZ}
		{exclusiveGroupIcon  moveBVertexmain edgeLenBB}
        }
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_MatchEdges {} {
    if [ic_hex_blocking_loaded] {
        ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez mParamsDEZ}
		{exclusiveGroupIcon blockParam edgeParamMatchEdge}
        }
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_RescaleOGrid {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editBlockMenuDEZ}
		{exclusiveGroupIcon editBlkmain rescaleOBlkB}
		{greyGroup rescaleOBlkSel 0}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_CheckQualityAR {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez hexQualityDEZ}
		{dropDownEntry qualitydde "Aspect ratio"}
    	}
    	aie_hex_update_histogram "Aspect ratio"
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_IndexReset {} {
    if [ic_hex_blocking_loaded] {
    	index_reset
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}


proc HotKey_ProjectVertsAll {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG projVUpdate}
		{greyGroup projVUpdateGG 0}
    	}
    	editProjDEZ apply
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_AlignVerts {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez moveBVertexDEZ}
		{exclusiveGroupIcon  moveBVertexmain AlignVerBB}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_ScaleMeshSize {} {
     if [ic_hex_blocking_loaded] {
     	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
	 	{dez mParamsDEZ}
	 	{exclusiveGroupIcon blockParam blockParamS}
     	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_CheckQualityAngle {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez hexQualityDEZ}
		{dropDownEntry qualitydde "Angle"}
        	}
    	aie_hex_update_histogram "Angle"
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_IndexSet {} {
    if [ic_hex_blocking_loaded] {
    	aie_hex_index_control
    	index_from_corners
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_AssocFace2Surf {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG assocFacSurf}
    	}   
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_GroupCurves {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG editComposite}
    	}
    	editProjDEZ set groupEGVal 0
    } else {mess "The 'Group Curves' hotkey is only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_IndexControl {} {
    if [ic_hex_blocking_loaded] {
    	aie_hex_index_control
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_SetLocation {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez moveBVertexDEZ}
		{exclusiveGroupIcon  moveBVertexmain SelLocBM}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_SetEdgeParams {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez mParamsDEZ}
		{exclusiveGroupIcon blockParam edgeParamS}
        	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}


    proc HotKey_CreateOGrid {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez splitBlkDEZ}
		{exclusiveGroupIcon splitBlk OgridBlkBlk}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_CheckQualityDet {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez hexQualityDEZ}
		{dropDownEntry qualitydde "Determinant 3x3x3"}
        	}
    	aie_hex_update_histogram "Determinant 3x3x3"
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_UngroupCurves {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG editComposite}
		{exclusiveGroupIcon groupEG ungroupEGI}
    	}
    	editProjDEZ set groupEGVal 1
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

    proc HotKey_ProjectVerts {} {
    if [ic_hex_blocking_loaded] {    
	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG projVUpdate}
		{greyGroup projVUpdateGG 1}
        }
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_Recompute {} {
     if [ic_hex_blocking_loaded] {
    	hex_mesh_up_to_date 0
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}



proc HotKey_SplitBlocks {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez splitBlkDEZ}
		{exclusiveGroupIcon splitBlk splitBlkBlk}
        }
    } else {mess "Blocking hotkey for 'Split Blocks' is only available when blocking is loaded, please load or initialize blocking.\n" red}
}


proc HotKey_SplitBlocksPropagate {} {
    if [ic_hex_blocking_loaded] {
     	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez splitBlkDEZ}
		{exclusiveGroupIcon splitBlk splitBlkExtend}
    	}
    } else {mess "Blocking hotkey for 'Extend Block Split' is only available when blocking is loaded, please load or initialize blocking.\n" red}
}


proc HotKey_MergeVerts {} { 
    if [ic_hex_blocking_loaded] {    
	    ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez mergeBVertexDEZ}
		{exclusiveGroupIcon mergeBVertexmain deleteBlkStationB}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}


proc HotKey_MergeVertsProp {} {
    if [ic_hex_blocking_loaded] {
        ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez mergeBVertexDEZ}
		{exclusiveGroupIcon mergeBVertexmain deleteBlkStationB}
        }
        mergeBVertexDEZ set propagate 1
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_MergeBlocks {} {
    if [ic_hex_blocking_loaded] { 
         ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editBlockMenuDEZ}
		{exclusiveGroupIcon editBlkmain joinBlockMethod}
        }
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_FixInverted {} {
    if [ic_hex_blocking_loaded] {    
	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez checkBlockDEZ}
		{exclusiveGroupIcon blockCheck invertInvertedBlock}	
        }
        checkBlockDEZ apply
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_SplitEdge {} {
    if [ic_hex_blocking_loaded] {    
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editEdgeMenuDEZ}
		{exclusiveGroupIcon editEdgemain editEdgeSplit}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_UnsplitEdge {} {
    if [ic_hex_blocking_loaded] {    
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editEdgeMenuDEZ}
		{exclusiveGroupIcon editEdgemain editEdgeUnSplit}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_Edge2Curve {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG assocEdge}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_Edge2Surf {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG assocEdgeSurf}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_MoveVerts {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez moveBVertexDEZ}
        {dropDownEntry MVHow Single}
		{exclusiveGroupIcon moveBVertexmain moveBVertexM}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_MoveVertsMult {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez moveBVertexDEZ}
		{dropDownEntry MVHow Multiple}
		{exclusiveGroupIcon moveBVertexmain moveBVertexM}
        	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_Vert2Point {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez editProjDEZ}
		{exclusiveGroupIcon editAssocEG assocVert}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_UpdateSizes {} {
    if [ic_hex_blocking_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Blocking"}
		{dez mParamsDEZ}
		{exclusiveGroupIcon blockParam blockParamM}
    	}
    } else {mess "Blocking hotkeys are only available when blocking is loaded, please load or initialize blocking.\n" red}
}

proc HotKey_MergeFaces {} {
    if [ic_hex_blocking_loaded] {	
        ::AIEnv::GUIManagement::InvokeUserActions {
    	{tab "Blocking"}
		{dez editBlockMenuDEZ}
		{exclusiveGroupIcon editBlkmain joinBlockFace}
        }
    } else {mess "The 'Merge Faces' hotkey is only available when blocking is loaded, please load or initialize blocking.\n" red}
}


##############################Edit Mesh Section##############################


proc HotKey_MergeNodes {} {
    global tdv_current_viewer plot_window histogram_args histo_status colorBand
    if [ic_uns_is_loaded] {
        if {[info exists plot_window] && [winfo exists $plot_window.graph]} {
            set recreate_plot 1
            if [info exists histogram_args] {
                set recreate_args $histogram_args
            }
            if [info exists histo_status] {
                array set recreate_status [array get histo_status]
            }
            if [info exists colorBand] {
                 array set recreate_band [array get colorBand]
            }
        }
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez mergeNodesDEZ}
		{checkItem mergeNodesPropagFlag 0}
		{checkItem mergeNodesAveFlag 0}
		{checkItem mergeNodesForceFlag 1}
		{exclusiveGroupIcon mergeNodesEG mergeInterRM}
    	}
        if [info exists recreate_plot] {
            if [info exists recreate_args] {
                set histogram_args $recreate_args
            }
            if [info exists recreate_status] {
                array set histo_status [array get recreate_status]
            }
            aie_redraw_histogram
            if [info exists recreate_band] {
                array set colorBand [array get recreate_band]
                aie_create_colorband $colorBand(actual_min) $colorBand(actual_max) \
                                     $colorBand(xvals) $colorBand(color_by_quality)
                histo_highlight $plot_window 1 smooth_show_elements {}
            }
        } 
    } else {mess "The 'Merge Nodes' hotkey is only available when Mesh is loaded.\n"  red}
}

proc HotKey_MergeNodesProp {} {
    if [ic_uns_is_loaded] {
        ::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez mergeNodesDEZ}
		{checkItem mergeNodesPropagFlag 1}
		{checkItem mergeNodesAveFlag 0}
		{checkItem mergeNodesForceFlag 1}
		{exclusiveGroupIcon mergeNodesEG mergeInterRM}
        }
    } else {mess "The 'Merge Nodes => Propagate' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_SplitEdges {} {
     if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
	    {tab "Edit Mesh"}
	    {dez splitMeshDEZ}
	    {greyGroup SplitEdgeGG 0}
	    {checkItem split_propagate 0}
	    {checkItem split_project 1}
	    {exclusiveGroupIcon editElemsGG splitEdge}
	    }
	    ::AIEnv::GUIManagement::ToggleGrey splitEdgeRatio 1
    } else {
        if [ic_str_is_loaded] {
    	    ::AIEnv::GUIManagement::InvokeUserActions {
		    {tab "Edit Mesh"}
		    {dez splitStrMeshDEZ}
		    }
		} else {
            mess "The 'Split Edges/Mesh' hotkey is only available when Mesh is loaded.\n" red
        }
    }
}

proc HotKey_SplitEdgesPropagate {} {
     if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
	    {tab "Edit Mesh"}
	    {dez splitMeshDEZ}
	    {greyGroup SplitEdgeGG 0}
	    {checkItem split_propagate 1}
	    {checkItem split_project 1}
	    {exclusiveGroupIcon editElemsGG splitEdge}
	}
	set grey 0
	if {[ic_uns_dimension] <= 2} {
	    set grey 1
	}
	::AIEnv::GUIManagement::ToggleGrey splitEdgeRatio $grey
     } else {mess "The 'Split Edges' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_RemeshBadElements {} {
     if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez repairMeshDEZ}
		{dropDownEntry elType "Quad Dominant"}
		{checkItem repairSurfProjFlag 1}
		{checkItem ignoreDimFlag 0}	
		{exclusiveGroupIcon repairMeshRG repairMeshRMB}
    	}
#     	::AIEnv::GUIManagement::InvokeUserActions {
#	{tab "Blocking"}
#    	}
    } else {mess "The 'Remesh Bad Elements' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_RemeshElements {} {
    global tdv_current_viewer plot_window histogram_args histo_status colorBand
    if [ic_uns_is_loaded] {
        if {[info exists plot_window] && [winfo exists $plot_window.graph]} {
            set recreate_plot 1
            if [info exists histogram_args] {
                set recreate_args $histogram_args
            }
            if [info exists histo_status] {
                array set recreate_status [array get histo_status]
            }
            if [info exists colorBand] {
                 array set recreate_band [array get colorBand]
            }
        }
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez repairMeshDEZ}
		{dropDownEntry elType "Quad Dominant"}
		{checkItem repairSurfProjFlag 1}
		{checkItem repairInterPolFlag 0}
		{textEntry offsetLayerFlag 0}
		{textEntry offsetHeightFlag 1.0}
		{exclusiveGroupIcon repairMeshRG repairMeshRM}
    	}
        if [info exists recreate_plot] {
            if [info exists recreate_args] {
                set histogram_args $recreate_args
            }
            if [info exists recreate_status] {
                array set histo_status [array get recreate_status]
            }
            aie_redraw_histogram
            if [info exists recreate_band] {
                array set colorBand [array get recreate_band]
                aie_create_colorband $colorBand(actual_min) $colorBand(actual_max) \
                                     $colorBand(xvals) $colorBand(color_by_quality)
                histo_highlight $plot_window 1 smooth_show_elements {}
            }
        } 
    } else {mess "The 'Remesh Elements' hotkey is only available when Mesh is loaded.\n" red}
}

proc Hotkey_MeshFromEdges {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez repairMeshDEZ}
		{dropDownEntry elType "Quad Dominant"}
		{checkItem repairSurfProjFlag 1}
		{checkItem repairSurfCompEdgeFlag 1}
		{checkItem repairInterPolFlag 0}
		{checkItem KeepConsistentFlag 0}
		{exclusiveGroupIcon repairMeshRG closeHoleMesh}
    	}
    } else {mess "The 'Mesh From Edges' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_BuildMeshTopo {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez repairMeshDEZ}
		{exclusiveGroupIcon repairMeshRG repairMeshBT}
    	}
    } else {mess "The 'Build Mesh Topo' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_Node2Curve {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez moveNodesDEZ}
		{exclusiveGroupIcon moveNodesGG moveNodesProjCurve}
    	}
    } else {mess "The 'Project Nodes to Curve' hotkey is only available when Mesh is loaded.\n" red}
}


proc HotKey_Node2Surf {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez moveNodesDEZ}
		{exclusiveGroupIcon moveNodesGG moveNodesProjSurf}
    	}
    } else {mess "The 'Project Nodes to Surface' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_Node2Point {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez moveNodesDEZ}
		{exclusiveGroupIcon moveNodesGG moveNodesProjPoint}
    	}
    } else {mess "The 'Project Node to Point' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_SnapProjectNodes {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez moveNodesDEZ}
		{exclusiveGroupIcon moveNodesGG moveNodesUpProj}
    	}
    } else {mess "The 'Snap Project Nodes' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_MoveNodes {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez moveNodesDEZ}
		{checkItem allow_invert 0}	
		{exclusiveGroupIcon moveNodesType moveNodesSingle}
		{exclusiveGroupIcon moveNodesGG moveNodesInter}
    	}
    } else {
        if [ic_str_is_loaded] {
    	    ::AIEnv::GUIManagement::InvokeUserActions {
		    {tab "Edit Mesh"}
		    {dez moveStrNodesDEZ}
		    }
		} else {
		    mess "The 'Move Nodes' hotkey is only available when Mesh is loaded.\n" red
    	}
    }
}

proc HotKey_MoveNodesMult {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez moveNodesDEZ}
		{checkItem allow_invert 0}
		{exclusiveGroupIcon moveNodesType moveNodesMultiple}
		{exclusiveGroupIcon moveNodesGG moveNodesInter}
	
    	}
    } else {mess "The 'Move Nodes (Multiple)' hotkey is only available when Mesh is loaded.\n" red}
}


proc HotKey_SwapEdges {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez splitMeshDEZ}
		{exclusiveGroupIcon editElemsGG swapEdge}
    	}
    	
    	
    } else {mess "The 'Swap Edges' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_Tri2Quad {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez convertMeshTypeDEZ}
		{checkItem projectFlag 1}
		{checkItem quadrizationFlag 0}
		{checkItem improvementFlag 1}
		{exclusiveGroupIcon convertMeshTypeGG triToQuad}
    	}
    } else {mess "The 'Tri 2 Quad' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_AllTri2Quad {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez convertMeshTypeDEZ}
		{checkItem projectFlag 1}
		{checkItem quadrizationFlag 1}
		{checkItem improvementFlag 1}
		{exclusiveGroupIcon convertMeshTypeGG triToQuad}
    	}
    } else {mess "The 'All Tri 2 Quad (With Quadrization)' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_Quad2Tri {} {
     if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez convertMeshTypeDEZ}
		{exclusiveGroupIcon convertMeshTypeGG quadToTri}    
    	}
    } else {mess "The 'Quad 2 Tri' hotkey is only available when Mesh is loaded.\n" red}
}

proc GlobalHotKey_Diagnostics {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez checkMeshDEZ}
    	}
    } else {mess "The 'Edit Mesh => Diagnostics' hotkey is only available when Mesh is loaded.\n" red}
}

proc HotKey_DeleteElements {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez deleteElemsDEZ}
    	}
    } else {mess "The 'Delete Mesh' hotkey is only available when Mesh is loaded.\n" red}
}



proc HotKey_MeshQualityMetrics {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez qualityMetricsDEZ}
		{exclusiveGroupIcon qualDiag diagCustom}
    	}
    } else {
        if [ic_str_is_loaded] {
    	    ::AIEnv::GUIManagement::InvokeUserActions {
		    {tab "Edit Mesh"}
		    {dez qualityStrMeshDEZ}
		    }
    	} else {
            mess "The 'Edit Mesh => Quality metrics' hotkey is only available when Mesh is loaded.\n" red
        }
    } 
}

proc HotKey_SmoothMesh {} {
    if [ic_uns_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Edit Mesh"}
		{dez smoothDEZ}
		}
    } else {
        if [ic_str_is_loaded] {
    	    ::AIEnv::GUIManagement::InvokeUserActions {
		    {tab "Edit Mesh"}
		    {dez smoothStrMeshDEZ}
		    }
		} else {
            mess "The 'Edit Mesh => Smooth Mesh' hotkey is only available when Mesh is loaded.\n" red
    	}
    }
}

proc HotKey_CreateElem {} {    
    ::AIEnv::GUIManagement::InvokeUserActions {
	{tab "Edit Mesh"}
	{dez createElemsDEZ}
	{greyGroup createElemsRG  3}
	{checkItem makeConsistent 0}
    }
}

###############################Geometry Tab Hotkeys ##########################

proc HotKey_BuildTopo {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez repairGeomDEZ}
		{exclusiveGroupIcon repairSurfaceEG repairGeoTopo}
    	}
    } else {mess "The Geometry hotkey for Build Topo is only available when Geometry is loaded.\n" red}
}

proc HotKey_ExtendSurf {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createSurfsDEZ}
		{exclusiveGroupIcon createSurfsEXG createExtSurfEdge}
    	}
    } else {mess "The Geometry hotkey for Extend Surface is only available when Geometry is loaded.\n" red}
}

proc HotKey_StitchMatch {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez repairGeomDEZ}
		{exclusiveGroupIcon repairSurfaceEG repairSurMatch}
    	}
    } else {mess "The Geometry hotkey for Stitch/Match Surface Edges is only available when Geometry is loaded.\n" red}
}

proc HotKey_DeleteGeom {} {
	set ::vid_options(DelPerFlag) 0
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez deleteEntityDEZ}
    	}
    } else {mess "The Delete Geometry hotkey is only available when Geometry is loaded.\n" red}
}

proc HotKey_DeleteGeomPerm {} {
	# set global variable before invoke dez: If autopickmode - it will "pick"
	set ::vid_options(DelPerFlag) 1
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez deleteEntityDEZ}  
    	}
    } else {mess "The Delete Geometry (Permanently) hotkey is only available when Geometry is loaded.\n" red}
}

proc HotKey_SplitCurve {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createCurvesDEZ}  
		{exclusiveGroupIcon createCurvesEXG createCrvSegment}
    	}
    } else {mess "The Geometry hotkey for Split Curve is only available when Geometry is loaded.\n" red}
}

proc HotKey_SplitSurf {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createSurfsDEZ}  
		{exclusiveGroupIcon createSurfsEXG createSurfTrim}
    	}
    } else {mess "The Geometry hotkey for Split Surface is only available when Geometry is loaded.\n" red}
}

proc HotKey_CurtainSurf {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createSurfsDEZ}  
		{exclusiveGroupIcon createSurfsEXG createSurfCurtain}
    	}
    } else {mess "The Geometry hotkey for Curtain Surface is only available when Geometry is loaded.\n" red}
}

proc HotKey_OffsetSurf {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createSurfsDEZ}  
		{exclusiveGroupIcon createSurfsEXG createSurfOffset}
    	}
    } else {mess "The Geometry hotkey for Offset Surface is only available when Geometry is loaded.\n" red}
}

proc HotKey_CreateCurve {} {
    ::AIEnv::GUIManagement::InvokeUserActions {
	{tab "Geometry"}
	{dez createCurvesDEZ}  
	{exclusiveGroupIcon createCurvesEXG createCrvPnts}
    }
}

proc HotKey_Curve2Surf {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createCurvesDEZ}  
		{exclusiveGroupIcon createCurvesEXG createCrvProj}
    	}
    } else {mess "The Geometry hotkey for Proj Curve to Surface is only available when Geometry is loaded.\n" red}
}

proc HotKey_ConcatCurves {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createCurvesDEZ}  
		{exclusiveGroupIcon createCurvesEXG createCrvConcat}
    	}
    } else {mess "The Geometry hotkey for Concatonate Curves is only available when Geometry is loaded.\n" red}
}

proc HotKey_CreateSurf {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createSurfsDEZ}  
		{exclusiveGroupIcon createSurfsEXG createSurfSimple}
    	}
    } else {mess "The Geometry hotkey for creating a surface from curves is only available when Geometry is loaded.\n" red}
}

proc HotKey_MergeSurfs {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createSurfsDEZ}  
		{exclusiveGroupIcon createSurfsEXG modifyMergeSurf}
    	}
    } else {mess "The Geometry hotkey for Merge Surfaces is only available when Geometry is loaded.\n" red}
}

proc HotKey_Point2Curve {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createPointsDEZ}  
		{exclusiveGroupIcon createPointsEXG createPointCurvProj}
    	}
    } else {mess "The Geometry hotkey for Point to Curve is only available when Geometry is loaded.\n" red}
}

proc HotKey_Point2Surf {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createPointsDEZ}  
		{exclusiveGroupIcon createPointsEXG createPointprojSurf}
    	}
    } else {mess "The Geometry hotkey for Point to Surface is only available when Geometry is loaded.\n" red}
}

proc HotKey_MoveGeom {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez transformSurfsToolsDEZ} 
  		{greyGroup copyTranslateGG  0}  
		{exclusiveGroupIcon transfrmSurfsEG transMoveSurfsEGI}
    	}
    } else {mess "The Move Geometry hotkey is only available when Geometry is loaded.\n" red}
}

proc HotKey_CopyGeom {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez transformSurfsToolsDEZ} 
		{greyGroup copyTranslateGG  1} 
		{exclusiveGroupIcon transfrmSurfsEG transMoveSurfsEGI}
    	}
    } else {mess "The Copy Geometry hotkey is only available when Geometry is loaded.\n" red}
}

proc HotKey_FacetedTools {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createFacetedDEZ} 
		{exclusiveGroupIcon Faceted_0_EXG modFaceSrf }
    	}
    } else {mess "The Geometry hotkey for Faceted Tools is only available when Geometry is loaded.\n" red}
}

proc HotKey_FacetMV2NEW {} {
    if [ic_geo_is_loaded] {
    	::AIEnv::GUIManagement::InvokeUserActions {
		{tab "Geometry"}
		{dez createFacetedDEZ} 
		{exclusiveGroupIcon Faceted_0_EXG modFaceSrf }
          		{exclusiveGroupIcon modifyFacetSurfEXG modFaceSrf_12 }
    	}
    } else {mess "The Geometry hotkey for Move Facets to a new Part is only available when Geometry is loaded.\n" red}
}

##################  Development Hotkeys ########################

proc HotKey_CreateCylinder {} {
    global tdv_current_viewer
    if ![ic_geo_is_loaded] ic_empty_tetin
    ic_geo_new_family GEOM
    ic_boco_set_part_color GEOM 
    ic_surface cyl GEOM srf.00 {{0 0 0} {1 0 0} 0.5 0.5 1 1}
    aie_update_gui geom
    tdv_scale_to_fit $tdv_current_viewer
}

proc HotKey_CreateMeshedCylinder {} {
    global tdv_current_viewer

    HotKey_CreateCylinder
    ic_geo_new_family SOLID
    ic_hex_multizone_blocking -inherited -uface_type all_quads -volfam SOLID
    ic_hex_set_unstruct_face_method auto
    ic_hex_set_mesh 16 17 n 10 h1 1.0 h2 1.0 r1 2 r2 2 lmax 1e+010 default unlocked
    ic_hex_set_mesh 14 15 n 5 h1 1.0 h2 1.0 r1 2 r2 2 lmax 1e+010 default unlocked
    ic_hex_set_mesh 15 16 n 5 h1 1.0 h2 1.0 r1 2 r2 2 lmax 1e+010 default unlocked
    ic_hex_set_mesh 12 14 n 5 h1 1.0 h2 1.0 r1 2 r2 2 lmax 1e+010 default unlocked
    ic_hex_set_mesh 16 12 n 5 h1 1.0 h2 1.0 r1 2 r2 2 lmax 1e+010 default unlocked
    ic_hex_create_mesh GEOM SOLID proj 2 dim_to_mesh 3
}

proc HotKey_CreateBox {} {
    global tdv_current_viewer
    if ![ic_geo_is_loaded] ic_empty_tetin
    ic_geo_new_family GEOM
    ic_boco_set_part_color GEOM 
    ic_vid_object box8 GEOM 00 {0 0 0} 1 1 1
    aie_update_gui geom
    tdv_scale_to_fit $tdv_current_viewer
}

global batch_mode

if !$batch_mode {
    bind . <Shift-Control-Alt-C> "HotKey_CreateCylinder"
    bind . <Shift-Control-Alt-M> "HotKey_CreateMeshedCylinder"
    bind . <Shift-Control-Alt-B> "HotKey_CreateBox"
}
##################  Global Hotkeys ########################

proc HotKey_SaveHardCopy {} {
    if ![hardcopyDEZ isbuilt] {
	hardcopyDEZ build
    }
    hardcopyDEZ setdirty
    hardcopyDEZ apply
}

set more_options_to_add {
    
    
    P  => Edit mesh => Edit nodes => Project nodes => Change projection
    order up one (surface to curve, curve to Point)
    
    <SHFT> P  => Edit mesh => Edit nodes => Project nodes => Change
    projection order down one (Point to curve, curve to surface) 
    
    <CTRL> P  => Edit mesh => Edit nodes => Project nodes => Current Type
    
    
    # This function does not yet exist in AI*E
    <SHFT> W  => Edit mesh => Edit edges => Swap => Automatic
    
    
    <SHFT> T  => Edit mesh => Change type => Tri -> Quad (Quadrization ON)
    
    
    
    If it is not too much difficulty, then having "V" toggle between display
    options "wire frame" and "solid wire", like J does for surfaces, would
    be great.
    
}






