-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mkdir -p ./trame_vtk/modules/common/serve | ||
curl https://unpkg.com/vue-vtk-js@3.1.6 -Lo ./trame_vtk/modules/common/serve/trame-vtk.js | ||
curl https://kitware.github.io/vtk-js/examples/OfflineLocalView/OfflineLocalView.html -Lo ./trame_vtk/tools/static_viewer.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
graft trame_vtk/modules/common/serve | ||
include trame_vtk/LICENSE | ||
include trame_vtk/tools/static_viewer.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__("pkgutil").extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from trame_vtk.tools.vtksz2html import main | ||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import argparse | ||
import base64 | ||
from pathlib import Path | ||
import sys | ||
|
||
HTML_VIEWER_PATH = Path(__file__).with_name("static_viewer.html") | ||
|
||
|
||
def embbed_data_to_viewer(input_data_file_path): | ||
input = Path(input_data_file_path) | ||
output = input.with_name(f"{input.name}.html") | ||
base64Content = "" | ||
|
||
if input.exists(): | ||
with open(input, "rb") as data: | ||
dataContent = data.read() | ||
base64Content = base64.b64encode(dataContent) | ||
base64Content = base64Content.decode().replace("\n", "") | ||
|
||
with open(HTML_VIEWER_PATH, mode="r", encoding="utf-8") as srcHtml: | ||
with open(output, mode="w", encoding="utf-8") as dstHtml: | ||
for line in srcHtml: | ||
if "</body>" in line: | ||
dstHtml.write("<script>\n") | ||
dstHtml.write( | ||
"var container = document.querySelector('.content');\n" | ||
) | ||
dstHtml.write('var base64Str = "%s";\n\n' % base64Content) | ||
dstHtml.write( | ||
"OfflineLocalView.load(container, { base64Str });\n" | ||
) | ||
dstHtml.write("</script>\n") | ||
|
||
dstHtml.write(line) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="HTML exporter for local view data") | ||
|
||
parser.add_argument( | ||
"--input", | ||
help="Input data file", | ||
) | ||
|
||
args, _ = parser.parse_known_args() | ||
|
||
if args.input is None: | ||
parser.print_help() | ||
sys.exit(0) | ||
|
||
input_file = Path(args.input) | ||
if not input_file.exists(): | ||
parser.print_help() | ||
sys.exit(0) | ||
|
||
embbed_data_to_viewer(input_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters