Challenge

Week - 7 - Checking and correcting the edges

Report week 7 Checking and correcting the edges

Objective:Complete checking and correcting the edges tasks

Problem Statement:

PART A:

  • Create a code that displayed free and T edges for displayed elements
  • Free edge color red and T edge cyan
  • Except for edges, all other components must be made transparent
  • Also, temp nodes must be automatically created for “free nodes” for a tolerance value of 0.01

PART B:

  • Also, create a code to turn off free edge display and restore the window to the way it was.
  • Map these codes over a key and also create a tk widget for the same

Tcl command explanation:

(create window)

set a .window
catch {destroy $a}
toplevel $a -class toplevel
wm title $a "Edge Control"
wm geometry $a 300x240+100+200

(create buttons)

button $a.02 -text "Free Edge" -command {FreeEdges} -font {times 10 bold}; place $a.02 -x 40 -y 70 -width 100 -height 25
button $a.03 -text "T Edge" -command {TEdges} -font {times 10 bold}; place $a.03 -x 160 -y 70 -width 100 -height 25
button $a.04 -text "Both" -command {Both} -font {times 10 bold}; place $a.04 -x 100 -y 110 -width 100 -height 25
button $a.06 -text "Hide" -command {HIDE} -font {times 10 bold}; place $a.06 -x 100 -y 190 -width 100 -height 25

(show free edge function)

proc FreeEdges {} {
*setdisplayattributes 4 1
*createmark elements 1 "displayed"
if {[hm_entityinfo exist comps FreeEdges ]==0 } {
*findedges1 elements 1 0 0 0 30
*setvalue comps name={^edges} name={FreeEdges}
*createmark components 1 "FreeEdges"
*setvalue components mark=1 color=3
*createmark elems 1 "displayed"
*equivalence elems 1 0.01 0 0 0
*equivalence elems 1 0.01 3 0 0
*createmark nodes 1 "retrieve"
*nodemarkaddtempmark 1
} else {
tk_messageBox -message "Already Exists" -icon info -type ok
}
}

(show T edge function)

proc TEdges {} {
*setdisplayattributes 4 1
*createmark elements 1 "displayed"
if {[hm_entityinfo exist comps TEdges ]==0 } {
*findedges1 elements 1 0 0 0 30
*setvalue comps name={^edges} name={TEdges}
*createmark components 1 "TEdges"
*setvalue components mark=1 color=30
} else {
tk_messageBox -message "Already Exists" -icon info -type ok
}
}

(show both function)
proc Both {} {
FreeEdges;
TEdges;
}

(hide both function)
proc HIDE {} {
*createmark components 1 "FreeEdges" "TEdges"
*deletemark components 1
*setdisplayattributes 2 0
*clearmark nodes 1
*nodecleartempmark 1
}

Conclusion: task is completed with above code

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.