
# This code creates the user interface for the mesh editor.
#
# Copyright (c) 1997 Pacific Marketing and Consulting, Inc,
#       and ICEM Systems, GmbH.  All rights reserved.
# Author:  Wayne A. Christopher, wayne@icemcfd.com
# All the menu-specific stuff, logos, etc go in this file.  This makes it
# easier to create flavored versions of med with different structures.
#
# Toolbars -----------

command_make_toolbar "File commands" 1 {
    "save sm"
    "exit sm"
    "Print screen"
}
#The following are two commands specifically for Batch Surface meshing
#===========================================
command_define "save sm" "Save nastran" save_icon \
    "file_savenas" {
    } no_help always
#the file_savenas and file_exitnas procs are at end of file
command_define "exit sm" "Save nastran and exit" done_icon \
    "file_exitnas" {
    } no_help always
#======================================
command_make_toolbar "Editing commands" 1 {
    "Undo operation"
    "Redo operation"
}

command_make_toolbar "Orientation commands" 1 {
    "Home position"
    "Zoom in"
    "Scale to fit"
    { cascade ""
    "Orient positive X" 
    "Orient negative X" 
    "Orient positive Y" 
    "Orient negative Y" 
    "Orient positive Z" 
    "Orient negative Z" 
    "Isometric view" 
    "Reverse orientation" 
    }
}

command_make_toolbar "Tool commands" 1 {
    "Distance" 
    "Location"  
    "Coord systems" 
}

command_make_toolbar "Geometry commands" -2 {
    { cascade ""
	"Create surface from 8 points (box)"
	"Create surface from 4 points"
	"Create curve from points"
	"Intersect surfaces"
	"Extract curve from surface"
   	"Create surface from convex hull"
    }
 
    { cascade data_available(geom)
	"Create topology"
	"Fix gaps (CAD)"
    }
    "Change geometry family"
    { cascade data_available(geom)
	"Model mesh params"
	"Family mesh params"
	"Entity mesh params"
    }
    "Copy/move selected entities"
    "Delete selected geometry"
}

command_make_toolbar "Geometry surf edit commands" -2 {
     { cascade data_available(geom)
    	"Segment surface"
    	"Segment curve"
    	"Merge surfaces"
    	"Untrim surface"
    	"Rename surface"
    	"Convert surface to facets"
   	"Coarsen surface"
      }

    { cascade data_available(geom)
	"Delete surface triangles"
      	"Create surface triangles"
      	"Move surface triangles to existing surface"
	"Move surface triangles to new surface"
	"Restrict surface triangles"
    }
    { cascade data_available(geom)
    	"Split edges"
    	"Swap edges"
    	"Split surface triangles"
	"Merge surface nodes interactive"
	"Merge surface nodes by tolerance"
	"Move surface nodes to location"
	"Move surface nodes on screen"
	"Move surface nodes on plane"
	"Move surface nodes on line"
	"Move surface nodes in direction"
    }
}

command_make_toolbar "Meshing commands" -2 { 
    { cascade data_available(geom)
	"Quad"
	"Tetra batch from CAD" 
	"Hexa interactive" 
    }

}
command_make_toolbar "Mesh Editing commands" 2 { 
    { cascade data_available(unstruct)
    	  "Unstructured quality metrics"
	  "Smooth elements"
    }
    "Repair unstructured mesh"
    "Check mesh"
    "Change element family" 
    "Copy/move mesh" 
   { cascade data_available(unstruct)
	  "1 Quad -> 2 Tri" 
	  "Tri -> Quad" 
	  "Coarsen elements" 
	  "Refine elements"  
   }
   "Create elements" 
   "Delete selected elements" 
   { cascade data_available(unstruct)
	"Split selected edges" 
	"Swap edges (try harder)" 
	"Split selected elements" 
   }
   { cascade data_available(unstruct)
    	"Move unstruct node (invert)" 
    	"Move unstruct node (exact)" 
   }
   { cascade data_available(unstruct)
   	"Merge unstruct nodes (interactive" 
   	"Merge unstruct nodes (selected, tolerance)" 
   }
   { cascade data_available(unstruct)
	"Project unstruct nodes to surfaces"
	"Project unstruct nodes to curves" 
	"Project unstruct nodes to points" 
	"Unproject unstruct nodes" 
   }
}



# Key bindings ---------
command_set_hotkeys {
    F1 "Help"
    z "Zoom in"
    o "Open project"
}


# Pulldown menus ---------

command_make_menu "Help" "" "right button" {}

command_make_menu "File" "" left {
    { "Open" "" cascade {
        { "Open project" }
        { "Load tetin file" }
        { "Load domain file" }
        { "Load family_boco file" }
    } }
    { "Save" "" cascade {
        { "Save project" }
        { "Save tetin file" }
        { "Save domain file" }
        { "Save family_boco file" }
    } }
    { "Save as" "" cascade {
        { "Save project as" }
        { "Save tetin file as" }
        { "Save domain file as" }
        { "Save family_boco file as" }
    } }
    { "Close" "" cascade {
        { "Close project" }
        { "Unload tetin file" }
        { "Unload domain file" }
        { "Unload family_boco file" }
    } }
    { "Delete" "" cascade {
        { "Delete project" }
        { "Delete tetin file" }
        { "Delete domain file" }
        { "Delete family_boco file" }
        { "Delete DDN part" }
    } }
    { "Quit" }
    separator
    { "Import geometry" "" cascade {
        { "Import domain file as geometry" }
        { "Import Plot3d as geometry" }
        { "Import Patran as geometry" }
        { "Import STL as geometry" }
        { "Import Fluent as geometry" }
        { "Import Rampant as geometry" }
        { "Import VRML as geometry" }
        { "Import Capri as geometry" }
        { "Import CATIA4 as geometry" }
        { "Import IGES" }
        { "Import DDN" }
        { "Import UG" }

	  separator
        { "Convert IGES to DDN" }
        { "Convert TVDA to DDN" }
        { "Convert DXF to DDN" }
        { "Convert PreBFC to DDN" }
        { "Move DDN part to other dir" }
        { "Copy DDN part to other dir" }
        { "Copy DDN part" }
        { "Rename DDN part" }
    } }
    { "Export geometry" "" cascade {
        { "Convert Tetin to IGES" }
        { "Convert Tetin to DDN" }
        { "Convert DDN to IGES" }
        { "Convert DDN to TVDA" }
        { "Convert DDN to DXF" }
        { "Move DDN part to other dir" }
        { "Copy DDN part to other dir" }
        { "Copy DDN part" }
        { "Rename DDN part" }
        { "Convert CGM to Postscript" }
    } }
    { "Import mesh" "" cascade {
	{ "Import Plot3d as mesh" }
        { "Import STL as mesh" }
        { "Import Ansys as mesh" }
        { "Import Patran as mesh" }
        { "Import Nastran as mesh" }
        { "Import Fluent as mesh" }
        { "Import Starcd as mesh" }
    } }
    { "Export mesh" "" cascade {
 	 { "Select solver" }
   	 { "Solver params" }
   	 { "Solver input" }
   	 { "Start solver" }
    } }
     separator
    { "Print screen" }
    { "Text Editor" }
    { "Shell window" "" cascade {
	{ "Shell window in current dir" }
	{ "Shell window in transfer dir" }
	{ "Shell window in mesh dir" }
    } }
    { "Project Utilities" "" cascade {
    	{ "Convert directory style" }
	{ "Copy project" }
	{ "Rename project" }
	{ "Archive project" }
	{ "Un-archive project" }
    } }
    { "Check system info" }
    { "Configuration" "" cascade {
	    { "Change directory" }
	    { "Edit pathnames" }
 	    { "Change ICEM_ACN" }
	    { "Clear file locks" }
	    { "License" "" cascade {
		{ "Start license server" }
		{ "Reconnect to license server" }
		{ "Check license usage" }
 	   } }
    } }
    { "Play game" }
}

command_make_menu "Edit" "" left {
    { "Undo operation" }
    { "Redo operation" }
    separator
    { "Edit toolbars" }
    { "Edit options" }
    { "Mouse bindings" }
    { "Coord systems" }
    separator
    { "Transfer facets -> mesh" }
    { "Transfer mesh -> facets" }
}

command_make_menu "View" "" left {
    { "Orient" "" cascade {
	{ "Home position" }
	{ "Zoom in" }
	{ "Scale to fit" }
	{ "Orient positive X" }
	{ "Orient negative X" }
	{ "Orient positive Y" }
	{ "Orient negative Y" }
	{ "Orient positive Z" }
	{ "Orient negative Z" }
	{ "Isometric view" }
	{ "Reverse orientation" }
    } }
    { "Set background" }
    { "Track mouse" } 
    separator
    { "Coord axes" }
    { "Origin marker" }
    { "Depthcue" }
    { "Tcl console" }
}

command_make_menu "Geometry" {data_available(geom)} left {
    { "Create" "" cascade {
	{ "Segment surface" }
	{ "Create surface from 4 points" }
	{ "Create surface from 8 points (box)" }
	{ "Create surface from convex hull" }
	separator
	{ "Segment curve" }
	{ "Extract curve from surface" }
	{ "Intersect surfaces" }
	{ "Create curve from points" }
	separator
	{ "Extract points from curve" }
	{ "Create points via screen select" }
	{ "Create points via screen midpoint" }
	{ "Create points via explicit location" }
	separator
	{ "Create material via screen select" }
	{ "Create material via screen midpoint" }
	{ "Create material via explicit location" }
	separator
	{ "Create density via screen select" }
    } }
    { "Repair" "" cascade {
	{ "Create topology" }
	{ "Fix gaps (CAD)" }
	{ "Remove feature (CAD)" }
	{ "Fix gaps (faceted)" }
	{ "Delete duplicate facets" }
	{ "Delete unattached geometry" }
    } } 
    { "Edit Geometry" "" cascade {
	{ "Modify surfaces" "" cascade {
	    { "Untrim surface" }
	    { "Rename surface" }
	    { "Convert surface to facets" }
	    { "Merge surfaces" }
	    { "Coarsen surface" }
	    { "Edit triangles" "" cascade {
		{ "Create surface triangles" }
		{ "Delete surface triangles" }
		{ "Restrict surface triangles" }
		{ "Split surface triangles" }
		{ "Move surface triangles to existing surface" }
		{ "Move surface triangles to new surface" }
	    } }
	    { "Edit edges" "" cascade {
		{ "Split edges" }
		{ "Swap edges" }
	    } }
	    { "Move nodes" "" cascade {
		{ "Move surface nodes to location" }
		{ "Move surface nodes on screen" }
		{ "Move surface nodes on plane" }
		{ "Move surface nodes on line" }
		{ "Move surface nodes in direction" }
	    } }
	    { "Merge nodes" "" cascade {
		{ "Merge surface nodes interactive" }
		{ "Merge surface nodes by tolerance" }
	    } }
	} }
	{ "Modify curves" "" cascade {
	    { "Rename curve" }
	    { "Convert curve to facets" }
	    { "Merge curves" }
	    { "Reapproximate curve" }
	    { "Edit segments" "" cascade {
		{ "Create curve segments" }
		{ "Delete curve segments" }
		{ "Restrict curve segments" }
		{ "Split curve segments" }
		{ "Move to other curve" "" cascade {
		    { "Move curve segments to existing" }
		    { "Move curve segments to new" }
		} }
	    } }
	    { "Move nodes" "" cascade {
		{ "Move curve nodes to location" }
		{ "Move curve nodes on screen" }
		{ "Move curve nodes on surfaces" }
		{ "Move curve nodes on plane" }
		{ "Move curve nodes on line" }
		{ "Move curve nodes in direction" }
	    } }
	    { "Merge curve nodes" }
	} }
	{ "Modify points" "" cascade {
	    { "Rename point" }
	    { "New point position" }
	    { "Screen move point" }
	    { "Merge points" }
	} }
	{ "Modify materials" "" cascade {
	    { "Rename material" }
	    { "New material position" }
	    { "Screen move material" }
	} }
	{ "Modify densities" "" cascade {
	    { "Rename density" }
	    { "Move density corner" }
	} }
    } }
    { "Delete geometry" data_available(geom) cascade {
	{ "Delete selected geometry" }
	{ "Delete last created objects" }
	{ "Delete all visible objects" }
	{ "Delete all blanked objects" }
    } }
    { "Meshing setup" "" cascade {
	{ "Model mesh params" }
	{ "Family mesh params" }
	{ "Entity mesh params" }
	separator
	{ "Loops" "" cascade {
		{ "Create loop via screen select" }
		{ "Create loop from surfaces" }
		{ "Create loop from each surface" }
    	} }
    	{ "Cartesian setup" "" cascade {
		{ "Init Cartesian (minimal)" }
		{ "Init  Cartesian(keypoints)" }
		{ "Load cart file" }
		{ "Save cart file" }
		separator
		{ "Display Cartesian stations" }
		{ "Add Cartesian stations" }
		{ "Delete Cartesian stations" }
		{ "Edit Cartesian stations" }
		{ "Edit Cartesian ranges" }
		{ "Edit Cartesian cyl params" }
		separator
		{ "Cartesian mesh" }
		{ "Cylindrical mesh" }
    	} }
    } }
    { "Change geometry family" }
    { "Copy/move geometry" "" cascade {
	{ "Copy/move whole model" }
	{ "Copy/move families" }
	{ "Copy/move selected entities" }
    } }
}

command_make_menu "Mesh" {data_available(mesh)} left {
    { "Create mesh" "" cascade {
 	   { "Hexa" "" cascade {
		{ "Hexa interactive" }
		{ "Hexa batch" }
		{ "Convert Mulcad to Hexa" }
	    } }
	    { "Tetra" "" cascade {
		{ "Tetra batch from CAD" }
		{ "Tetra interactive from CAD" }
		{ "Tetra from surface mesh" }
	    } }
 	   { "Global" }
 	   { "Prism" }
 	   { "Quad" }
 	   { "AutoHexa" }
 	   separator
 	   { "Mulcad/Padamm" "" cascade {
		{ "Run Mulcad" }
		{ "Clean up Mulcad scratch files" }
	    } }
	    { "P-Cube" "" cascade {
		{ "P-Cube" }
		{ "Delete P-Cube undo files" }
		{ "Set P-Cube tolerance" }
	    } }
    } }
    { "Diagnostics" data_available(mesh) variable_cascade data_available(unstruct) {
	{ 0 "Structured diagnostics" {
	    { "Structured quality metrics" }
	    { "Domain orientation" }
	    { "Structured summary info" }
    	    { "Full topo info" }
	} }
	{ 1 "Unstructured diagnostics" {
	    { "Information" "" cascade {
		{ "Unstructured summary info" }
		{ "Unstructured element info" }
		{ "Unstructured node info" }
		{ "Unstructured domain file info" }
		{ "Max vertex degree" }
	    } }
	    { "Which elements" "" cascade {
		{ "Diagnostic elements: All" }
		{ "Diagnostic elements: Active" }
		{ "Diagnostic elements: Subset" }
	    } }
	    { "Unstructured quality metrics" }
	    { "Errors" "" cascade {
		{ "Duplicate elements" }
		{ "Volume orientation" }
		{ "Surface orientation" }
		{ "Uncovered faces" }
		{ "Missing internal faces" }
		{ "Periodic problems" }
	    } }
	    { "Possible problems" "" cascade {
		{ "Overlapping elements" }
		{ "Delaunay violations" }
		{ "Single edges" }
		{ "2 single edges" }
		{ "Multiple edges" }
		{ "Single/multiple edges" }
		separator
		{ "Triangle boxes" }
		{ "Non-manifold vertices" }
		{ "Stand-alone surface mesh" }
		{ "Family boundary edges" }
		{ "Check edges" }
		separator
		{ "Disconnected vertices" }
		{ "Spanning edges" }
	    } }
	} }
    } }
    { "Smooth elements" }
    { "Change family" data_available(mesh) variable_cascade data_available(unstruct) {
	{ 0 "" {
	    { "Change domain family" }
	    { "Change subface family" }
	    { "Change edge family" }
	    { "Change vertex family" }
	} }
	{ 1 "" {
	    { "Change element family" }
	} }
    } }
    { "Copy/move mesh" }
    separator
    { "Edit Mesh" data_available(mesh) cascade {
  	  { "Repair unstructured mesh" data_available(mesh) }
	  { "Edit nodes" data_available(mesh) variable_cascade data_available(unstruct) {
		{ 0 "" {
		    { "Move struct node exact" }
		    { "Move struct node screen" }
		    { "Move struct nodes on geometry" }
		} }
		{ 1 "" {
		    { "Move" "" cascade {
			{ "Move unstruct node (invert)" }
			{ "Move unstruct node (no invert)" }
			{ "Move unstruct node (exact)" }
		    } }
		    { "Merge" "" cascade {
			{ "Merge unstruct nodes (interactive" }
			{ "Merge unstruct nodes (all, tolerance)" }
			{ "Merge unstruct nodes (selected, tolerance)" }
			{ "Merge unstruct nodes (visible, tolerance)" }
		    } }
		    { "Delete unstruct nodes" }
		    { "Project" "" cascade {
			{ "Project unstruct nodes to surfaces" }
			{ "Project unstruct nodes to curves" }
			{ "Project unstruct nodes to points" }
			{ "Project unstruct nodes to current type" }
			{ "Unproject unstruct nodes" }
			{ "Project unstruct nodes automatic" }
			{ "Project unstruct nodes from surves to surfaces" }
		    } }
		    { "Split" "" cascade {
			{ "Split nodes manifold" }
			{ "Split nodes non-manifold" }
		    } }
		    { "Set projection mode" "" cascade {
			{ "Projection mode: active families" }
			{ "Projection mode: all families" }
			{ "Projection mode: no projection" }
		    } }
		    { "Periodic" "" cascade {
			{ "Make nodes periodic" }
			{ "Make nodes not periodic" }
		    } }
		} }
	    } }
	    { "Edit elements" "data_available(unstruct)" cascade {
		{ "Create elements" }
		{ "Delete" "" cascade {
		    { "Delete selected elements" }
		    { "Delete all blanked elements" }
		} }
		{ "Change element orientation" }
		{ "Split" "" cascade {
		    { "Split selected elements" }
		    { "Split internal faces" }
		    { "Split double walls" }
		    { "Split prisms" }
		} }
		{ "Couplings" "" cascade {
		    { "Create couplings" }
		    { "Clear couplings" }
		} }
		{ "Renumber elements" }
	    } }
	    { "Edit edges" "data_available(unstruct)" cascade {
		{ "Split" "" cascade {
		    { "Split selected edges" }
		    { "Split spanning edges" }
		} }
		{ "Swap" "" cascade {
		    { "Swap edges (simple)" }
		    { "Swap edges (try harder)" }
		    { "Swap edges (automatic)" }
		} }
	    } }
	    { "Edit domains" data_available(struct) cascade {
		{ "Reorient domains" }
	    } }
	    { "Edit subfaces" data_available(struct) cascade {
		{ "Split subfaces" }
		{ "Merge subfaces" }
	    } }
    } }
    { "Refine elements" }
    { "Coarsen elements" }
    { "Change type" data_available(mesh) cascade {
	{ "Prisms -> Tetras" }
	{ "Linear -> Quadratic" }
	{ "Quadratic -> Linear" }
	{ "1 Quad -> 2 Tri" }
	{ "Tri -> Quad" }
	{ "12 Tetra -> 1 Hexa" }
	{ "1 Tetra -> 4 Hexa" }
	{ "1 Prism -> 3 Tetra" }
	{ "All -> Tetra" }
    } }
    { "Merge unstructured meshes" }
    { "Extrude elements" }
    { "Uncouple elements" }
    { "Optimize bandwidth" }
    { "Utilities" data_available(mesh) cascade {
	{ "Edit properties" }
	{ "Make consistent" }
	{ "Check edges" }
    } }
}

command_make_menu "Tools" "" left {
    { "Distance" }
    { "Location" }
    { "Bounding box" } 
    { "Frontal area" }
    separator
    { "DDN tools" "" cascade {
	{ "DDN" }
	{ "Comak" }
	{ "Input" }
	{ "Frontal (in DDN)" }
    } }
    { "Visual3" }
    { "MOM3D" }
    { "RAMM-ICE" }
    { "Moving Mesh" }
    { "Y+" }
    separator
    { "Bound conds" }
    { "Manage coord. systems" }
    separator
    { "Scripting" "" cascade {
        { "Run script" }
        { "Replay mode" }
        { "View programmer's guide" }
    } }
    separator
    { "Add marker" }
    { "Clear markers" }
    { "Annotations" }
}

proc file_savenas_real { } {
    #global sm xxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    ic_save_unstruct $sm(name)_offset.uns
    set out_file $sm(export_dir)/$sm(name).nas
    scrib_lib_output_nastran $out_mesh $out_boco $out_file
}

proc file_savenas { } {
    
}

proc file_exitnas { } {
    file_savenas
    exit
}


