package require java
proc informServer {value current_function_name plane_mode} {
set plane [$plane_mode getCurrentValue]
set current_function [$current_function_name getCurrentValue]
if {[string compare "[string tolower $current_function ]" "digitiser digitise"] != 0 && $value == "drafting"} {
return
}
if {$value == "projection"} {
if {[string compare "[string tolower $plane]" "plane mode on"] == 0 &&
[string compare "[string tolower $current_function ]" "digitiser digitise"] == 0} {
set value "on"
if {[ GuidoSSIOption get "snap projection" ] == "on"} {
set value "off"
}
GuidoExecServer "SetSSIOption" [subst {key = "snap projection" option = "$value" sync = "false"}]
GuidoSSIOption status_set "snap projection" "$value"
}
return
}
set current_function [$current_function_name getCurrentValue]
if {[string compare "[string tolower $current_function ]" "digitiser select"] == 0} {
return
}
if {[string compare "[string tolower [$current_function_name getCurrentValue]]" ""] == 0} {
set clientManager [java::call com.surpac.client.ClientManager getSharedInstance]
$clientManager invokeServerCommand "SNAP $value"
} else {
GuidoExecServer "SetSSIOption" [subst {key = "snap mode" option = "$value" sync = "false"}]
GuidoSSIOption status_set "snap mode" "$value"
if {[string compare "[string tolower $value]" "off"] == 0} {
if {[string compare "[string tolower $plane]" "plane mode on"] == 0} {
GuidoSSIOption status_set "snap mode icon" "plane"
} else {
GuidoSSIOption status_set "snap mode icon" "off"
}
} else {
GuidoSSIOption status_set "snap mode icon" "$value"
}
}
}
GuidoMenu snapMode {
-icon "icons/<iconsize>/snap_off.png"
-tip "Snap Mode. Click to cycle through modes."
-status_item_icon "snap mode icon" "plane" "icons/<iconsize>/snap_plane.png"
-status_item_icon "snap mode icon" "off" "icons/<iconsize>/snap_off.png"
-status_item_icon "snap mode icon" "drafting" "icons/<iconsize>/snap_drafting.png"
-status_item_icon "snap mode icon" "point" "icons/<iconsize>/snap_point.png"
-status_item_icon "snap mode icon" "line" "icons/<iconsize>/snap_line.png"
-status_item_icon "snap mode icon" "triangle" "icons/<iconsize>/snap_triangle.png"
-status_item_icon "snap mode icon" "drafting" "icons/<iconsize>/snap_drafting.png"
GuidoField snapmode_toolbar_current_function_name {
-default ""
-status_item "current function name"
-visible false
}
GuidoField plane_mode {
-default ""
-status_item "plane_mode"
-visible false
}
GuidoCheckBoxMenuItem snapOff {
-icon "icons/16/snap_off.png"
-label "No Snap"
-tip "No snapping will be performed"
-status_item "snap mode" "off"
-action mouseReleased {[informServer off $snapmode_toolbar_current_function_name $plane_mode]}
-dependency {[string compare "[string tolower [$snapmode_toolbar_current_function_name getCurrentValue]]" "digitiser select"] != 0}
}
GuidoCheckBoxMenuItem snapPoint {
-icon "icons/16/snap_point.png"
-label "Point"
-tip "Snap to the nearest point"
-status_item "snap mode" "point"
-action mouseReleased {[informServer point $snapmode_toolbar_current_function_name $plane_mode]}
-dependency {[string compare "[string tolower [$snapmode_toolbar_current_function_name getCurrentValue]]" "digitiser select"] != 0}
}
GuidoCheckBoxMenuItem snapLine {
-icon "icons/16/snap_line.png"
-label "Line"
-tip "Snap to the nearest line"
-status_item "snap mode" "line"
-action mouseReleased {[informServer line $snapmode_toolbar_current_function_name $plane_mode]}
-dependency {[string compare "[string tolower [$snapmode_toolbar_current_function_name getCurrentValue]]" "digitiser select"] != 0}
}
GuidoCheckBoxMenuItem snapTriangle {
-icon "icons/16/snap_triangle.png"
-label "Triangle"
-tip "Snap to nearest triangle"
-status_item "snap mode" "triangle"
-action mouseReleased {[informServer triangle $snapmode_toolbar_current_function_name $plane_mode]}
-dependency {[string compare "[string tolower [$snapmode_toolbar_current_function_name getCurrentValue]]" "digitiser select"] != 0}
}
GuidoCheckBoxMenuItem snapDrafting {
-icon "icons/16/snap_drafting.png"
-label "Drafting"
-tip "Snap with a drafting ruler"
-status_item "snap mode" "drafting"
-action mouseReleased {[informServer drafting $snapmode_toolbar_current_function_name $plane_mode]}
-dependency {[string compare "[string tolower [$snapmode_toolbar_current_function_name getCurrentValue]]" "digitiser digitise"] == 0}
}
GuidoSeparator sep1 {
}
GuidoCheckBoxMenuItem projectPoints {
-label "Project selections to plane"
-tip "Project selected points onto the plane during digitiser select events"
-status_item "snap projection" "on"
-action mouseReleased {[informServer projection $snapmode_toolbar_current_function_name $plane_mode]}
-dependency {"[$plane_mode getCurrentValue]" == "Plane mode on" && [string compare "[string tolower [$snapmode_toolbar_current_function_name getCurrentValue]]" "digitiser digitise"] == 0}
}
GuidoLabel labelChanger {
-dependency {"[$plane_mode getCurrentValue]" == "Plane mode on"}
-action stateChanged {[if {"[$plane_mode getCurrentValue]" == "Plane mode on"} {$snapOff setLabel "Plane"} else {$snapOff setLabel "No Snap"}]}
-action stateChanged {[if {"[$plane_mode getCurrentValue]" == "Plane mode on"} {$snapOff setIconByName icons/16/snap_plane.png} else {$snapOff setIconByName icons/16/snap_off.png}]}
}
}
