base-prototype
This commit is contained in:
parent
0538a059d9
commit
13642c2f06
|
@ -6,9 +6,10 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="f609c0f2-cd0d-4eea-87f1-8caf02d3f04f" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frame/ContentView.py" beforeDir="false" afterPath="$PROJECT_DIR$/frame/ContentView.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/graph/DataType.py" beforeDir="false" afterPath="$PROJECT_DIR$/graph/DataType.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/graph/directed_acyclic_graph/DAGLayout.py" beforeDir="false" afterPath="$PROJECT_DIR$/graph/directed_acyclic_graph/DAGLayout.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/graph/directed_acyclic_graph/DAGPresent.py" beforeDir="false" afterPath="$PROJECT_DIR$/graph/directed_acyclic_graph/DAGPresent.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/parse/StoryMap.py" beforeDir="false" afterPath="$PROJECT_DIR$/parse/StoryMap.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -40,6 +41,7 @@
|
|||
"keyToString": {
|
||||
"Python.CompareViews.executor": "Run",
|
||||
"Python.CompareWindow.executor": "Run",
|
||||
"Python.ContentView.executor": "Run",
|
||||
"Python.DAGGraph (1).executor": "Run",
|
||||
"Python.DAGGraph.executor": "Run",
|
||||
"Python.DAGLayout (1).executor": "Run",
|
||||
|
@ -59,7 +61,7 @@
|
|||
"settings.editor.selected.configurable": "reference.settings.ide.settings.new.ui"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="Python.DAGPresent">
|
||||
<component name="RunManager" selected="Python.ContentView">
|
||||
<configuration name="CompareViews" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="StoryTools" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
|
@ -82,6 +84,28 @@
|
|||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="ContentView" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="StoryTools" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/frame" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/frame/ContentView.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="DAGLayout" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="StoryTools" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
|
@ -149,6 +173,7 @@
|
|||
<method v="2" />
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Python.ContentView" />
|
||||
<item itemvalue="Python.DAGLayout" />
|
||||
<item itemvalue="Python.DAGPresent" />
|
||||
<item itemvalue="Python.CompareViews" />
|
||||
|
@ -156,6 +181,7 @@
|
|||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.ContentView" />
|
||||
<item itemvalue="Python.DAGPresent" />
|
||||
<item itemvalue="Python.DAGLayout" />
|
||||
<item itemvalue="Python.CompareViews" />
|
||||
|
|
|
@ -1,4 +1,61 @@
|
|||
from PyQt5.QtWidgets import QApplication, QWidget
|
||||
from networkx import DiGraph
|
||||
import networkx as nx
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout
|
||||
from graph.directed_acyclic_graph.DAGPresent import DAGActiveView, Direction
|
||||
from parse.StoryMap import StoryMap, FragmentSlice, XAST_ParseTool
|
||||
from graph.DataType import Arrow, Point
|
||||
import sys
|
||||
from typing import Dict,List
|
||||
from parse.ast_load import global_ast_path
|
||||
|
||||
|
||||
class FragmentPoint(Point):
|
||||
def __init__(self, name: str, start_mark: bool):
|
||||
Point.__init__(self, name, start_mark)
|
||||
pass
|
||||
|
||||
|
||||
class ContentWindow(QWidget):
|
||||
def __init__(self, parent):
|
||||
QWidget.__init__(self, parent)
|
||||
layout = QVBoxLayout(self)
|
||||
self.fragment_view = DAGActiveView(Direction.RankLR, self)
|
||||
layout.addWidget(self.fragment_view)
|
||||
pass
|
||||
pass
|
||||
|
||||
def present_stories_graph(self, graph: Dict[str, StoryMap]) -> None:
|
||||
arrows: List[Arrow] = []
|
||||
for story_name in graph:
|
||||
fragments = graph[story_name].slice_list
|
||||
for fragi in range(1, len(fragments)):
|
||||
start_frag = fragments[fragi - 1]
|
||||
start_node_label = f"{start_frag.parent_story}&{start_frag.is_define_node[1]}"
|
||||
if not start_frag.is_define_node[0]:
|
||||
start_node_label = f"{start_frag.story_refer}&{start_frag.fragm_refer}"
|
||||
if fragi == 1:
|
||||
start_node_label = story_name
|
||||
|
||||
end_frag = fragments[fragi]
|
||||
end_node_label = f"{end_frag.parent_story}&{end_frag.is_define_node[1]}"
|
||||
if not end_frag.is_define_node[0]:
|
||||
end_node_label = f"{end_frag.story_refer}&{end_frag.fragm_refer}"
|
||||
|
||||
arrows.append(Arrow(
|
||||
FragmentPoint(start_node_label, fragi == 1),
|
||||
FragmentPoint(end_node_label, False))
|
||||
)
|
||||
pass
|
||||
pass
|
||||
|
||||
self.fragment_view.update_with_edges(arrows)
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
view = ContentWindow(None)
|
||||
view.show()
|
||||
|
||||
tool = XAST_ParseTool(global_ast_path)
|
||||
view.present_stories_graph(tool.get_story_graph())
|
||||
|
||||
app.exec()
|
|
@ -12,15 +12,16 @@ class Pos:
|
|||
|
||||
|
||||
class Point:
|
||||
def __init__(self, name:str):
|
||||
def __init__(self, name:str, start_mark: bool):
|
||||
self.point_name = name
|
||||
self.is_start = start_mark
|
||||
pass
|
||||
|
||||
def name(self) -> str:
|
||||
return self.point_name
|
||||
|
||||
def make_copy(self) -> 'Point':
|
||||
return Point(self.point_name)
|
||||
return Point(self.point_name, self.is_start)
|
||||
|
||||
|
||||
class Line:
|
||||
|
|
Binary file not shown.
|
@ -86,7 +86,7 @@ class PenetrateNode(QGraphicsItem, GraphNode):
|
|||
self.data_bind: object = None
|
||||
pass
|
||||
|
||||
def resize(self, width: float):
|
||||
def resize_width(self, width: float):
|
||||
self.width_store = width
|
||||
self.update()
|
||||
pass
|
||||
|
@ -177,9 +177,10 @@ class Direction(Enum):
|
|||
class DAGActiveView(QGraphicsView):
|
||||
def __init__(self, orie: Direction, parent):
|
||||
QGraphicsView.__init__(self, parent)
|
||||
self.setViewportUpdateMode(QGraphicsView.ViewportUpdateMode.FullViewportUpdate)
|
||||
|
||||
self.layer_span = 200
|
||||
self.node_span = 50
|
||||
self.node_span = 20
|
||||
|
||||
self.orientation = orie
|
||||
self.scene_bind = QGraphicsScene(self)
|
||||
|
@ -216,7 +217,7 @@ class DAGActiveView(QGraphicsView):
|
|||
all_graphics_nodes.append(curr_gnode)
|
||||
self.scene_bind.addItem(curr_gnode)
|
||||
else:
|
||||
if layer_idx == 0:
|
||||
if node.layer_bind.bind_point().is_start:
|
||||
curr_gnode = StoryFragmentNode(node.layer_bind.bind_point().point_name, StoryNodeType.StoryStartNode,
|
||||
self.font(), None)
|
||||
else:
|
||||
|
@ -238,8 +239,8 @@ class DAGActiveView(QGraphicsView):
|
|||
width_max = max(width_max, n.boundingRect().width())
|
||||
pass
|
||||
for n in all_graphics_nodes:
|
||||
if n is PenetrateNode:
|
||||
n.resize(width_max)
|
||||
if hasattr(n, "resize_width"):
|
||||
n.resize_width(width_max)
|
||||
pass
|
||||
pass
|
||||
|
||||
|
|
Binary file not shown.
|
@ -83,7 +83,7 @@ class XAST_ParseTool:
|
|||
if node.getAttribute("name") == name:
|
||||
mem_node = StoryMap(name)
|
||||
mem_node.sort_index = int(node.getAttribute("sort"))
|
||||
return (mem_node, node)
|
||||
return mem_node, node
|
||||
pass
|
||||
return None
|
||||
|
||||
|
@ -134,6 +134,12 @@ class XAST_ParseTool:
|
|||
pass
|
||||
pass
|
||||
pass
|
||||
|
||||
def get_story_graph(self) -> Dict[str, StoryMap]:
|
||||
story_dict = storyline_list2map(self.story_list)
|
||||
self.storylines_plait(story_dict)
|
||||
return story_dict
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue