/[fenfire]/fenfire/org/fenfire/bin/fenpdf10.py
ViewVC logotype

Diff of /fenfire/org/fenfire/bin/fenpdf10.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.82 by mudyc, Thu Sep 11 14:52:07 2003 UTC revision 1.83 by tjl, Wed Nov 5 10:25:49 2003 UTC
# Line 88  from org.nongnu.alph.impl import PageIma Line 88  from org.nongnu.alph.impl import PageIma
88    
89  from org.fenfire.fenpdf import actions  from org.fenfire.fenpdf import actions
90    
 from org.fenfire.fenpdf.fenpdfcontext import Context  
91    
92  # save and load  # save and load
93  from com.hp.hpl.mesa.rdf.jena.mem import ModelMem  from com.hp.hpl.mesa.rdf.jena.mem import ModelMem
94  import os.path  import os.path
95    
96  import vob  import vob
 w.setCursor('wait')  
97    
98    # Read the user-settable properties.
99    DIR = 'myFenfire/'
100    FILE = java.lang.System.getProperty("fenpdf.file", DIR+"mygraph.rdf")
101    POOLDIR = java.lang.System.getProperty("fenpdf.pool", DIR)
102    
 vob.putil.demo.usingNormalBindings = 0  
103    
104  ### debugs  # We're using the demo framework here (should eventually move
105  #ff.view.AreaSelectingView2D.dbg = 1  # out of it) but for now; set the flag to show that
106    # we don't want 'r' to reload; make the demo framework
107  # Java system property "fenpdf.file" can be used to set the file name -  # use Ctrl-R instead
108  # the default is "myFenfire/mygraph.rdf"  vob.putil.demo.usingNormalBindings = 0
109    
110    # Starting up takes a few seconds; show to the user the friendly
111    # wait cursor
112    w.setCursor('wait')
113    
114  DIR = 'myFenfire/'  # Now, before reading the xu stuff, render something
115    # to try to prevent NV driver
116    # fallback to software rendering.
117    # Might be that it only reserves screen memory when starting to render
118    # and if we reserve it all for textures, ... splat ...
119    vs = w.createVobScene()
120    vs.put(background((.8, .4, .9)))
121    w.renderStill(vs, 0)
122    
123  FILE = java.lang.System.getProperty("fenpdf.file", DIR+"mygraph.rdf")  ### debugs
124  POOLDIR = java.lang.System.getProperty("fenpdf.pool", DIR)  #ff.view.AreaSelectingView2D.dbg = 1
125    
126    # Create the pool directory if necessary
127    # (XXX NOT PORTABLE)
128  os.system('mkdir -p '+POOLDIR)  os.system('mkdir -p '+POOLDIR)
129    
130    # Create the storm and alph instances
131  pool = storm.impl.DirPool(java.io.File(POOLDIR), java.util.HashSet())  pool = storm.impl.DirPool(java.io.File(POOLDIR), java.util.HashSet())
132  myalph = alph.impl.StormAlph(pool)  myalph = alph.impl.StormAlph(pool)
133    
134    
135  # manual system to toggle the load point ;)  # If the file does exist, load it; otherwise, create
136  # first time put 0 in here,  # a new, empty graph, to be saved into that file.
 # then Qtrl-Q for quit and save  
 # then put load_toggle to 1 and rerun.  
 do_load_graph = 0  
   
 # automatic system for previous  
137  if os.path.isfile(FILE):  if os.path.isfile(FILE):
138      print 'Loading the RDF graph from the file %s.'% FILE      print 'Loading the RDF graph from the file %s.'% FILE
139      do_load_graph = 1      do_load_graph = 1
# Line 133  else: Line 142  else:
142      do_load_graph = 0      do_load_graph = 0
143    
144    
145  # Create fen with swamps.  # Create the fen with swamps.
146  fen = ff.Fen()  fen = ff.Fen()
147    fen.alph = myalph
148  if do_load_graph:  if do_load_graph:
149      m = ModelMem()      m = ModelMem()
150      m.read(java.io.FileReader(FILE), None)      m.read(java.io.FileReader(FILE), None)
151      fen.constgraph = fen.graph = ff.swamp.Graphs.toGraph(m)      fen.constgraph = fen.graph = ff.swamp.Graphs.toGraph(m)
152  else:  else:
153      fen.graph = fen.constgraph = ff.swamp.impl.HashGraph()      fen.constgraph = fen.graph = ff.swamp.impl.HashGraph()
154    
155  structure_ff = ff.structure.Ff.create(fen.graph, myalph)  # Create the enfilade/nodecontent structure
156    structure_ff = ff.structure.Ff.create(fen.graph, fen.alph)
157    treetime = ff.structure.TreeTime(TREETIME.follows)
158    
159  fen.enfiladeOverlap = structure_ff.getTransclusionIndex()  fen.enfiladeOverlap = structure_ff.getTransclusionIndex()
 fen.alph = myalph  
160    
 ppActions = ff.modules.pp.PPActionsImpl(fen, structure_ff)  
 treetime = ff.structure.TreeTime(TREETIME.follows)  
 ppActions.treeTime = treetime  
   
 # Now, before reading the xu stuff, render something  
 # to try to prevent NV driver  
 # fallback to software rendering.  
 # Might be that it only reserves screen memory when starting to render  
 # and if we reserve it all for textures, ... splat ...  
 vs = w.createVobScene()  
 vs.put(background((.8, .4, .9)))  
 w.renderStill(vs, 0)  
161    
162  # If we want a new space, create a demo space.  # If we want a new space, create a demo space.
163  if not do_load_graph:  if not do_load_graph:
164      val = java.lang.System.getProperty("fenpdf.demo")      val = java.lang.System.getProperty("fenpdf.demo")
165      if val != None and java.lang.Integer.parseInt(val) != 0:      if val != None and java.lang.Integer.parseInt(val) != 0:
166          ff.fenpdf.demospace.createDemoSpace(fen, myalph, treetime, ppActions,          ff.fenpdf.demospace.createDemoSpace(fen, myalph, treetime,
167                  structure_ff)                  structure_ff)
168      else:      else:
169          ff.fenpdf.demospace.createEmptySpace(fen, myalph, treetime, ppActions,          ff.fenpdf.demospace.createEmptySpace(fen, myalph, treetime,
170                  structure_ff)                  structure_ff)
171    
 # Default controls for main view  
 ## see http://himalia.it.jyu.fi/ffdoc/fenfire/pegboard/fenpdf_v1_spec_1--tjl/peg.gen.html and 'Bindings'  
   
   
   
 # print "APP",dir(ff.fenpdf.appearance)  
 # import org.fenfire.fenpdf.appearance.papers  
   
   
   
   
 #  
 # The first plane is the "firstOf" of the TREETIME follows  
 # relation.  
 # XXX Should also check type.  
 #  
 iter = fen.constgraph.findN_X11_Iter(TREETIME.firstOf, TREETIME.follows)  
 planeHome = iter.next()  
 if planeHome == None:  
     print "Error: home plane not found"  
     exit(42)  
 if not ppActions.isPaper(planeHome):  
     print "Error: home plane not found - wrong type ", planeHome  
     exit(42)  
   
   
   
 fenPDF = ff.fenpdf.fenpdf.FenPDF(fen, treetime, structure_ff)  
 fenPDF.window = w  
 fenPDF.events.buttons = ff.fenpdf.events.buttons.ActionButtons()  
 fenPDF.events.buttons.fenPDF = fenPDF  
   
   
 papers = ff.fenpdf.appearance.papers.Papers(fenPDF)  
   
 eventHandler = ff.fenpdf.events.eventhandler.EventHandler(fenPDF)  
 fenPDF.events.eventHandler = eventHandler  
   
   
 context = Context(w, fen, ppActions, FILE)  
172    
 context.states.selection =  \  
     fenPDF.uistate.selection = ff.fenpdf.fenpdfcontext.Selection()  
 context.fenPDF = fenPDF  
173    
 context.mousemenu = ff.fenpdf.events.mousemenu.MouseMenu(fenPDF, context.states)  
 fenPDF.events.mousemenu = context.mousemenu  
174    
 fenPDF.events.mouse = ff.fenpdf.events.mouse.MouseMapper(context)  
 fenPDF.events.key = ff.fenpdf.events.key.KeyHandler(context.states)  
175    
176    
177  views = ff.fenpdf.appearance.views.Views(fenPDF, papers,  fenPDF = ff.fenpdf.fenpdf.FenPDF(fen, treetime, structure_ff, w, FILE)
                 eventHandler,  
                 planeHome)  
 fenPDF.views = views  
 fenPDF.views.background = ff.fenpdf.appearance.background.FancyBlueBackground1()  
178    
 context.states.cursor = ff.fenpdf.fenpdfcontext.Cursor(fenPDF.structure.alphContent,  
                 views.getMultiplexerNodeContentFunction())  
 context.states.fenPDF = fenPDF  
 fenPDF.uistate.cursor = context.states.cursor  
179    
 eventHandler.context = context  
180    
181  ff.view.buoy.MainNode2D.fen = fen  # XXX THIS IS REALLY BAD ARCHITECTURALLY!
182  ff.view.buoy.AbstractMainNode2D.context = context  cursorRenderer = ff.fenpdf.fenpdfcontext.CursorRenderer(fenPDF)
183    ff.view.buoy.AbstractMainNode2D.context = cursorRenderer
184    
 fenPDF.actions.mouse = ff.fenpdf.actions.mouse.MouseActions(fenPDF,context)  
 fenPDF.actions.key = ff.fenpdf.actions.keyboard.KeyActions(context)  
 fenPDF.actions.menu = ff.fenpdf.actions.menu.MenuActions(fenPDF)  
 fenPDF.actions.abstract = ff.fenpdf.actions.abstract.AbstractActions(fenPDF)  
185    
186    
 fenPDF.events.mouse.fenPDF = fenPDF  
 fenPDF.events.mouse.update()  
187    
 fenPDF.events.key.fenPDF = fenPDF  
188    
 fenPDF.actions.key.fenPDF = fenPDF  
189    
190    
191                    
192    
193  class Scene:  class Scene:
194      def __init__(self):      def __init__(self):
         global context  
195    
196          w.setCursor('default')          w.setCursor('default')
197    
         self.context = context  
198    
199      def scene(self, vs):      def scene(self, vs):
200          scene = fenPDF.views.scene(vs)          scene = fenPDF.views.scene(vs)

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.83

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26