%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Example with Actions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% declare [Output] = {Link ['x-ozlib://niehren/davinci/output.ozf']} Inspect = Output.inspect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Graph-Specification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% declare Nodes = [%% nodes unit('OBJECT':'LA-LA' 'FONTFAMILY':helvetica 'INFO' :'This is a node!' edges :[unit('OBJECT': friends kind:light to:po) unit(kind:heavy to:po) unit(kind:heavy to:dipsy id:'1')] id :lala kind :lala) unit('OBJECT':'PO' id :po kinds :[po round]) unit('OBJECT':'DIPSY' edges :[unit(kind:light to:tinkywinky)] id :dipsy '_GO' :ellipse 'BORDER':double kind :dipsy) unit('OBJECT':'TINKY\\nWINKY' edges :[unit('OBJECT':lovers kind:light to:po)] id :tinkywinky kind :tinky) ] % Edges = [unit('from':dipsy to:po kind:light)] % Graph = unit(nodes:Nodes edges:Edges) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Graph specifications to be added later on %%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Subgraph specifications need as their first node %% the node where they are connected. (You must give at %% least it's id!) declare ToasterGraph = unit(edges: [unit(kind :light 'from' :dipsy to :tubbytoast)] nodes: [unit(id : tubbytoast 'OBJECT': 'TUBBYTOAST' '_GO' : rhombus )]) %% Independent new graphs must consist of new nodes and edges %% i.e. their identities must not be identical with already existing %% items declare HooverNodes = [unit(id : noonoo 'OBJECT':'Noo-noo hoover' '_GO' : image %ellipse 'IMAGE' : 'x-ozlib://niehren/davinci/examples/noonoo.gif' 'COLOR' : lightblue edges : [unit(to:dust) unit(to:dirt) unit('EDGECOLOR':pink to:pudding)]) unit('OBJECT':'Dirt' id : dirt) unit('OBJECT':'Dust' id : dust) unit('OBJECT':'Tubby Pudding' id : pudding 'COLOR' : pink)] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% (Layout)-Parameter- Specification %%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% In order to invoke actions you might create menues at nodes, %% edges or via icons and edit menu at the window. declare Parameters= unit( layout: unit( edge:unit( default: unit( 'EDGECOLOR' :black 'EDGEPATTERN':dashed '_DIR' :none 'HEAD' :farrow 'INFO' :"This is an edge." menu:[ menu_entry(RemoveEdge "Remove") edge_entry(Inspect "Inspect") ] ) light: unit('EDGECOLOR' :orange 'EDGEPATTERN':'double;solid;5;1' '_DIR' :normal menu:[ menu_entry(RemoveEdge "Remove") menu_entry(InvertLight "Invert") menu_entry(InspectEdge "Inspect") ] ) heavy: unit('EDGECOLOR' :blue 'EDGEPATTERN':solid '_DIR' :inverse menu:[ menu_entry(RemoveEdge "Remove") menu_entry(InvertHeavy "Invert") menu_entry(InspectEdge "Inspect") ] ) ) node:unit( default:unit('COLOR' :white '_GO' :text 'OBJECT' :'no text given' 'FONTSTYLE':italic 'INFO' :'nothing known about' menu:[submenu_entry( "Inspect" [menu_entry(InspectMenu "Node menu") menu_entry(InspectNode "Node") menu_entry(InspectInEdges "In-edges") menu_entry(InspectOutEdges "Out-edges") ]) menu_entry(WinkeNode "Winke(Winke)") submenu_entry('Remove' [menu_entry(RemoveNode "Node") menu_entry(RemoveSubgraph "Subgraph" ) ]) ]) round : unit('_GO' :circle) lala : unit('COLOR':yellow) dipsy : unit('COLOR':green) tinky : unit('COLOR':violet) po : unit('COLOR':red) ) %% Menus (to be found in 'Edit' menu) %% and icons for daVinci window. window:unit(menu: [ menu_entry(InspectGraph 'Inspect Graph') menu_entry(Quit 'Quit Application') submenu_entry('Add Subgraphs' [menu_entry(DrawHoover 'NooNoo Hoover') blank menu_entry(DrawToaster 'Tubby Toast') ]) submenu_entry('Configure' [menu_entry(thread {Config green} end "node-double-click: green") menu_entry(thread {Config red} end "node-double-click: red") ]) ] %% Icons have to be in X-Window Bitmap format (.xbm) %% of size 18x18 pixel. See dVDocumentation. icons:[icon_entry(WinkeAll URLExamples#'/hi.xbm' 'Winke Winke') icon_entry(Quit URLExamples#'/quit.xbm' 'Quit Application')] ) ) %% generic actions will be executed when edges or nodes are %% clicked on or if daVinci sends messages back: %% %% type actions = unit(edgeDoubleClick : edge x daVinci -> %% nodeDoubleClick : node x daVinci -> %% edgeSingleClick : edge x daVinci -> %% nodeSingleClick : node x daVinci -> %% communication_error: unit(value) x daVinci -> %% ok : daVinci ->) actions: unit(edgeDoubleClick : proc{$ Edge DaVinci} {DaVinci.change [edge(Edge unit('EDGECOLOR':black)) ]} end nodeDoubleClick : proc{$ Node DaVinci} {DaVinci.change [node(Node unit('COLOR':orange)) ]} end communication_error : proc{$ Answer DaVinci} {Inspect warning(msg :'daVinci communication error' answer:Answer)} end nodeSingleClick: proc{$ Node DaVinci} {Inspect 'single click on node:'#Node.id} end ok: proc{$ DaVinci} skip end ) %% List of atoms. Atoms are daVinci commands of %% category 'set' (see dV-Documentation) configuration: ['set(font_size(12))' 'set(gap_width(6))' 'set(gap_height(18))'] %% if set to true, communication with daVinci will be verbosed debugging: false %true ) %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Action Specification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% These are the actions to be executed when a menu entry is %% chosen. For procedures called at pop-up-menus, two arguments %% are expected, the first being the ItemId (NodeId or EdgeId), %% The second argument is the DaVinci-Environment which provides %% a set of actions on the graph as well as the state of the graph %% and the current selected edge and unit(s). %% Procedures invoked at the EditMenu and via Icons expect %% one argument namely the DaVinci-Environment. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% proc{InspectMenu Node _} {Inspect Node.menu} end proc{InspectNode Node _} {Inspect Node} end proc{InspectEdge Edge _} {Inspect Edge} end proc{InspectInEdges Node DaVinci} {Inspect {DaVinci.graph.inEdges Node}} end proc{InspectOutEdges Node DaVinci} {Inspect {DaVinci.graph.outEdges Node}} end %% %% actions of edges %% proc{InvertLight Edge DaVinci} {DaVinci.change [edge(Edge unit('_DIR':inverse menu :[ menu_entry(RemoveEdge 'Remove') menu_entry(InvertHeavy 'Invert') ])) ]} end %% proc{InvertHeavy Edge DaVinci} {DaVinci.change [edge(Edge unit('_DIR':normal menu:[ menu_entry(RemoveEdge 'Remove') menu_entry(InvertLight 'Invert') ])) ]} end %% %% actions of nodes %% proc{RemoveNode Node DaVinci} {DaVinci.remove.nodes [Node]} end %% proc{RemoveEdge Edge DaVinci} {DaVinci.remove.edges [Edge]} end %% proc{RemoveSubgraph Node DaVinci} {DaVinci.remove.subgraph Node} end %% proc{WinkeNode Node DaVinci} {Inspect 'Winke Winke '#Node.id} end %% %% actions of the window %% proc{WinkeMenu DaVinci} for Node in {DaVinci.selectedNodes} do {Inspect {VirtualString.toAtom 'Winke Winke '#Node.id#'!'}} end end %% proc{WinkeAll DaVinci} {Inspect 'Winke Winke!'} end %% proc{DrawToaster DaVinci} {DaVinci.add.subgraph ToasterGraph} end %% proc{DrawHoover DaVinci} {DaVinci.add.nodes HooverNodes} end %% proc{Quit DaVinci} {DaVinci.close} end %% proc{InspectGraph DaVinci} {DaVinci.graph.inspect} end %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% test configuration %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% fun{Config Color} Layout = unit(edge:unit(default:unit) node:unit(default: unit('_GO':circle menu:[menu_entry(Sorry 'Remove')] ) ) ) NewParameter = unit(parameter:unit(layout :Layout debugging:false) actions :TestActions ) %% proc{Sorry Node DV} {Inspect 'Sorry: no removal after configuration change:'} {Inspect Node} end %% TestActions = unit( nodeDoubleClick : proc{$ Node DaVinci} {DaVinci.change [node(Node unit('COLOR':Color)) ]} end ) in proc{$ DaVinci} {DaVinci.configure NewParameter} end end %% %% URLDaVinci = 'x-ozlib://niehren/davinci' URLExamples = URLDaVinci#'/examples' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Execution %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% declare [Interface] = {Link [URLDaVinci#'/manager.ozf']} DaVinci = {Interface.make Parameters} {DaVinci.newGraph Graph} {DaVinci.setTitle 'Actions Example'} {DaVinci.setSize 550#300}