Permalink
Browse files

Refs #881: added framework for xdot mode

* had to comment out wxversion stuff in wxxdot because wx is already loaded
  • Loading branch information...
1 parent 4312d30 commit af0777ef7b9414a59da89d3869c560fb772695e0 @robmcmullen committed Feb 23, 2012
Showing with 41 additions and 4 deletions.
  1. +30 −2 peppy/major_modes/graphviz.py
  2. +2 −2 peppy/third_party/wxxdot.py
  3. +9 −0 tests/samples/sample.xdot
@@ -26,6 +26,7 @@
from peppy.major import *
from peppy.editra.style_specs import unique_keywords
from peppy.fundamental import FundamentalMode
+from peppy.third_party.wxxdot import WxDotWindow
_sample_file = """// Sample graphviz source file
digraph G {
@@ -69,7 +70,7 @@ class GraphvizOutputFormat(RadioAction):
name = "Image Format"
default_menu = ("Graphviz", 500)
- items = ['eps', 'gif', 'jpg' ,'pdf', 'png', 'ps', 'svg']
+ items = ['xdot', 'eps', 'gif', 'jpg' ,'pdf', 'png', 'ps', 'svg']
def getIndex(self):
format = self.mode.classprefs.layout
@@ -105,7 +106,7 @@ class GraphvizMode(FundamentalMode):
StrParam('keyword_set_1', unique_keywords[127], hidden=False, fullwidth=True),
StrParam('path', '/usr/local/bin', 'Path to the graphviz binary programs\nlike dot, neato, and etc.'),
- StrParam('graphic_format', 'png'),
+ StrParam('graphic_format', 'xdot'),
StrParam('layout', 'dot'),
SupersededParam('output_log')
)
@@ -147,6 +148,32 @@ def finishedCallback(self, job):
self.frame.findTabOrOpen(self.dot_output)
+class XDotMode(WxDotWindow, STCInterface, MajorMode):
+ """
+ Major mode for viewing images. Eventually this may contain more
+ image manipulation commands like rotation, reflection, zooming,
+ etc., but not pixel editing features. Pixel editing features will
+ mean that the image will have to be decompressed into raw pixels.
+ This mode leaves the image in its native format.
+ """
+ keyword="XDot"
+ icon='icons/graphviz.png'
+
+ default_classprefs = (
+ StrParam('extensions', 'xdot', fullwidth=True),
+ )
+
+ def __init__(self, parent, wrapper, buffer, frame):
+ MajorMode.__init__(self, parent, wrapper, buffer, frame)
+ WxDotWindow.__init__(self, parent, -1)
+ self.update()
+
+ def update(self):
+ bytes = self.buffer.stc.GetBinaryData()
+ #dprint(repr(bytes))
+ self.set_xdotcode(bytes)
+
+
class GraphvizPlugin(IPeppyPlugin):
"""Graphviz plugin to register modes and user interface.
"""
@@ -155,6 +182,7 @@ def aboutFiles(self):
def getMajorModes(self):
yield GraphvizMode
+ yield XDotMode
def getActions(self):
yield SampleDot
@@ -94,8 +94,8 @@
__all__ = ['WxDotWindow', 'WxDotFrame']
# We need to get the wx version with built-in cairo support
-import wxversion
-wxversion.select("2.8")
+#import wxversion
+#wxversion.select("2.8")
import wx
import wx.lib.wxcairo as wxcairo
import cairo
@@ -0,0 +1,9 @@
+digraph G {
+ node [label="\N"];
+ graph [bb="0,0,68,108",
+ _draw_="c 9 -#ffffffff C 9 -#ffffffff P 4 0 -1 0 108 69 108 69 -1 ",
+ xdotversion="1.2"];
+ Hello [pos="34,90", width="0.83333", height="0.5", _draw_="c 9 -#000000ff e 34 90 30 18 ", _ldraw_="F 14.000000 11 -Times-Roman c 9 -#000000ff T 34 84 0 31 5 -Hello "];
+ World [pos="34,18", width="0.94444", height="0.5", _draw_="c 9 -#000000ff e 34 18 34 18 ", _ldraw_="F 14.000000 11 -Times-Roman c 9 -#000000ff T 34 12 0 37 5 -World "];
+ Hello -> World [pos="e,34,36.413 34,71.831 34,64.131 34,54.974 34,46.417", _draw_="c 9 -#000000ff B 4 34 72 34 64 34 55 34 46 ", _hdraw_="S 5 -solid c 9 -#000000ff C 9 -#000000ff P 3 38 46 34 36 31 46 "];
+}

0 comments on commit af0777e

Please sign in to comment.