📄 framedview
字号:
# Set case : create the title gobject if it does not exist yet if (![msge ${obj}.title exist]) { if (l[0]=="") {return -1} import args 1 `gclass.FramedView.default.titleFont font` msge $obj add 'title' Text -font font # Sets the position of the title {w h}=[setg ${obj} -size] {m1 m2 m3 m4}=[setg ${obj} -margin] if ((struct.reverse == 'y') || (struct.reverse == 'xy')) { setg ${obj}.title -posMode 'middle' 'down' -pos (w-m1-m3)/2+m1 15 } else { setg ${obj}.title -posMode 'middle' 'up' -pos (w-m1-m3)/2+m1 h-m4+10 } } setg ${obj}.title -string l[0] return -1 } # # The graph, graph+, graph1 and graph1+ fields # if ((field == "graph") || (field == "graph+") || (field == "graph1") || (field == "graph1+")) { if ((field == 'graph') || (field == 'graph1')) { msge $obj clear } s=l[0] type = type(s) if (type == '&range') { s = <s> type = type(s) } class=[gclass list '*' '*' type] if (class.length == 0) {errorf "Do not know how to display '%s' type structures" type} class=class[0] if (l.length == 1) {name =struct.n+1} else {name=l[1]} # Should we put axis and reverse the view and margins type1=type[1:] if ([var exist 1 disp.$type1]) { import args 1 `disp.$type1 def` if ([var exist def.axis]) {setg $obj -axis def.axis} if ([var exist def.margin]) { if ([msge ${obj}.^ class 'WindowDisp'] && ([setg ${obj}.^ -type] == type)) { {l t r b}=def.margin setg $obj -margin l t r b } } if ([var exist def.reverse]) {setg $obj -reverse def.reverse} } setg ${obj}.view -add name class -graph s struct.n+=1 if ((field == "graph") || (field == "graph+")) { setg ${obj}.view -bound '?' '?' '?' '?' return 1 } else {return -1} } # # The size and asize fields (we must reposition the box and the labels and the titles) # if ((field == 'asize') || (field == 'size')) { # Get case : just let the regular methods dealing with it if (l.length==0) {return} # Set case # We first need to remember the old size {ow oh}=[setg ${obj} -size] # Then perform the size changement setg Grid:$obj -$field l[0] l[1] # Get the new size {w h}=[setg $obj -size] # Then we have to change the box size {bw bh}=[setg ${obj}.box -size] setg ${obj}.box -pos 0 h-bh -size w bh {m1 m2 m3 m4}=[setg ${obj} -margin] # Then we have to change the xlabel position if there is any if ([msge ${obj}.xlabel exist]) { {ox oy}=[setg ${obj}.xlabel -pos] if ((struct.reverse == "x") || (struct.reverse == "none")) { y=oy } else { y = h-oh+oy } setg ${obj}.xlabel -pos (w-m3-m1)*(ox-m1)/(ow-m3-m1)+m1 y } # Then we have to change the ylabel position if there is any if ([msge ${obj}.ylabel exist]) { {ox oy}=[setg ${obj}.ylabel -pos] if ((struct.reverse == "x") || (struct.reverse == "xy")) { x = ox-ow+w } else { x =ox } setg ${obj}.ylabel -pos x (oy-m2)*(h-m2-m4)/(oh-m2-m4)+m2 } # Then we have to change the title position if there is any if ([msge ${obj}.title exist]) { {ox oy}=[setg ${obj}.title -pos] if ((struct.reverse == "y") || (struct.reverse == "xy")) { y=oy } else { y = (oy-m2)*(h-m2-m4)/(oh-m2-m4)+m2 } setg ${obj}.title -pos (w-m1-m3)/2+m1 y } return -1 } # # The margin field (we must reposition the box and the labels and the titles) # if (field == "margin") { # Get case : just let the regular methods dealing with it if (l.length==0) {return} # Save the previous margins {om1 om2 om3 om4}=[setg ${obj} -margin] {w h}=[setg $obj -size] # Perform the margin changement {m1 m2 m3 m4}=l setg Grid:$obj -margin m1 m2 m3 m4 # Then we have to change the xlabel position if there is any if ([msge ${obj}.xlabel exist]) { {ox oy}=[setg ${obj}.xlabel -pos] if ((struct.reverse == "x") || (struct.reverse == "none")) { setg ${obj}.xlabel -pos (w-m3-m1)*(ox-om1)/(w-om3-om1)+m1 oy-om2+m2 } else { setg ${obj}.xlabel -pos (w-m3-m1)*(ox-om1)/(w-om3-om1)+m1 oy-m4+om4 } } # Then we have to change the ylabel position if there is any if ([msge ${obj}.ylabel exist]) { {ox oy}=[setg ${obj}.ylabel -pos] if ((struct.reverse == "x") || (struct.reverse == "xy")) { x = ox+om3-m3 } else { x = ox-om1+m1 } setg ${obj}.ylabel -pos x (oy-om2)*(h-m2-m4)/(h-om2-om4)+m2 } # Then we have to change the title position if there is any if ([msge ${obj}.title exist]) { {ox oy}=[setg ${obj}.title -pos] {w h}=[setg $obj -size] if ((struct.reverse == "y") || (struct.reverse == "xy")) { y = oy-om2+m2 } else { y = (oy-om2)*(h-m2-m4)/(h-om2-om4)+m2 } setg ${obj}.title -pos (w-m1-m3)/2+m1 y } return -1 } # # The boundNoSync field (just call the same EView field) # if (field == 'boundNoSync') { if (l.length==0) {return [setg View:${obj}.view -bound]} # We first get the gobjects that must be yRescaled listObjResc={} listObj=[msge ${obj}.view list '*'] foreach o listObj { if ([setg ${obj}.view.$o -yRescaled]==1) {listObjResc += '${obj}.view.$o'} } # Hide them if (listObjResc.length != 0) { foreach u listObjResc { setg $u -hide 1 } } # Execute the command setg View:${obj}.view -bound l[0] l[1] l[2] l[3] # Show them again if (listObjResc.length != 0) { foreach u listObjResc { setg $u -hide 0 } } # And rescale them {a b c d}=[setg View:${obj}.view -bound] foreach o listObjResc { {a1 b1 c1 d1}=[setg $o -rect] if (d-c > 0) { setg $o -pos a1 c -size c1 d-c } else { setg $o -pos a1 d -size c1 c-d } } return 1 } # # The bound field (just call the same EView field) # if (field == "bound") { if (l.length == 0) {return [setg View:${obj}.view -bound]} {x0 x1 y0 y1}=l setg ${obj}.view -bound x0 x1 y0 y1 return 1 } # # The string field (just call the same Box field) # if (field == "string") { # We let the box handling the message if (l.length == 0) {return [setg ${obj}.box -string]} setg ${obj}.box -string l[0] return -1 } }## The general Drawing method#setproc _GFramedViewDraw {obj .l} { id=[msge $obj id] global `gclass.FramedView.$id struct` msge Grid:${obj} draw -g l[0] l[1] l[2] l[3] # Now we must draw the axis if (all(l==[setg ${obj}.box -rect])) {return} l=[setg ${obj}.view -rect] {x y w h}=l l=[setg ${obj}.view -bound] {xb yb wb hb}=l if (struct.axis) { if (struct.axisFrame && struct.ticksIn) { draw axis $obj x y w h xb yb wb hb -in -frame -margin struct.axisMargin -reverse struct.reverse -font struct.axisFont } elseif (struct.axisFrame) { draw axis $obj x y w h xb yb wb hb -frame -margin struct.axisMargin -reverse struct.reverse -font struct.axisFont } elseif (struct.ticksIn) { draw axis $obj x y w h xb yb wb hb -in -margin struct.axisMargin -reverse struct.reverse -font struct.axisFont } else { draw axis $obj x y w h xb yb wb hb -margin struct.axisMargin -reverse struct.reverse -font struct.axisFont } }}gclass new FramedView Grid %_GFramedViewSet %_GFramedViewMsge %_GFramedViewDraw "Graphic Class to display a View (actually \it uses EViews) with axis and a text box at the bottom. \It is used in WindowDisp and thus by the 'disp' function."proc delete %_GFramedViewSet %_GFramedViewMsge %_GFramedViewDraw
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -