Skip to content

Commit

Permalink
SCGV viewer supports batch mode...
Browse files Browse the repository at this point in the history
  • Loading branch information
lchorbadjiev committed Apr 16, 2019
1 parent ce78bbe commit 22ac95a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
47 changes: 47 additions & 0 deletions scgv/qtmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from PyQt5.QtWidgets import QApplication

from scgv.qtviews.main_window import MainWindow
from scgv.models.model import DataModel
from scgv.qtviews.canvas import Canvas

import os
import traceback
Expand Down Expand Up @@ -53,12 +55,57 @@ def main(argv=None):
'-V', '--version',
action='version', version=program_version_message)

parser.add_argument(
'-d', '--directory',
type=str,
dest='directory',
metavar='<dir name>',
help='load data from directory')

parser.add_argument(
'-o', '--output',
type=str,
dest='output',
metavar='<output filename>',
help='saves main view in a figure with specified filename')

parser.add_argument(
'-t', '--title',
type=str,
dest='title',
metavar='<figure title>',
help='adds title to the saved figure')

parser.add_argument(
'-r', '--resolution',
type=int,
dest='resolution',
metavar='<resolution>',
help='figure output resolution',
default=300)

args = parser.parse_args()
print(args)

if args.directory is not None and args.output is not None:
assert os.path.exists(args.directory)
model = DataModel(args.directory)
model.make()

canvas = Canvas()
canvas.model = model
canvas.redraw()
if args.title is not None:
canvas.fig.suptitle(args.title, fontsize=24)

canvas.fig.savefig(args.output, dpi=args.resolution)
return 0

app = QApplication(sys.argv)
window = MainWindow()
window.show()
if args.directory is not None:
window.open_buttons.load_model(args.directory)
app.exec_()

return 0
Expand Down
2 changes: 1 addition & 1 deletion scgv/qtviews/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Canvas(FigureCanvas):

def __init__(self, has_dendro=True):
self.model = None
self.fig = Figure(figsize=(12, 8))
self.fig = Figure(figsize=(24, 16))
super(Canvas, self).__init__(self.fig)
self.has_dendro = has_dendro
self.signals = CanvasSignals()
Expand Down
4 changes: 2 additions & 2 deletions scgv/qtviews/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(self, window):
def on_open_directory_click(self, s):
dirname = QFileDialog.getExistingDirectory(
self.window, "Open Directory")
self._load_model(dirname)
self.load_model(dirname)

def on_open_archive_click(self, s):
filter = "Zip File (*.zip)"
Expand All @@ -107,7 +107,7 @@ def on_open_archive_click(self, s):
".", filter)
self._load_model(filename)

def _load_model(self, filename):
def load_model(self, filename):

self.open_archive_action.setEnabled(False)
self.open_dir_action.setEnabled(False)
Expand Down
2 changes: 0 additions & 2 deletions scgv/views/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def _select_colormap(self):
self.cmap = self._select_colormap_size(size)

def draw_clone(self, ax):
print(self.model.clone)

if self.model.clone is not None:
ax.imshow(
Expand All @@ -53,7 +52,6 @@ def draw_clone(self, ax):
ax.set_yticklabels(["Clone"])

def draw_subclone(self, ax):
print(self.model.subclone)
if self.model.subclone is not None:
ax.imshow(
[self.model.subclone],
Expand Down

0 comments on commit 22ac95a

Please sign in to comment.