Skip to content

Commit 34d218a

Browse files
authored
Merge pull request #143 from qixinbo/master
make canvas independent
2 parents 993fbed + e13cd7d commit 34d218a

File tree

17 files changed

+326
-27
lines changed

17 files changed

+326
-27
lines changed

imagepy/app/imagepy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time, threading
33
sys.path.append('../../../')
44
import wx.lib.agw.aui as aui
5-
from sciwx.widgets import MenuBar, ToolBar, ChoiceBook, ParaDialog, WorkFlowPanel, ProgressBar
5+
from sciwx.widgets import MenuBar, RibbonBar, ToolBar, ChoiceBook, ParaDialog, WorkFlowPanel, ProgressBar
66
from sciwx.canvas import CanvasNoteBook
77
from sciwx.grid import GridNoteBook
88
from sciwx.mesh import Canvas3DNoteBook
@@ -147,6 +147,8 @@ def load_widget(self, data):
147147

148148
def init_menu(self):
149149
self.menubar = MenuBar(self)
150+
# self.menubar = RibbonBar(self)
151+
# self.auimgr.AddPane( self.menubar, aui.AuiPaneInfo() .CaptionVisible(False) .Top() .PinButton( True ).Dock().Resizable().MinSize(wx.Size(1000, 130)).FloatingSize( wx.DefaultSize ).Layer(5) )
150152

151153
def init_tool(self):
152154
sizer = wx.BoxSizer(wx.VERTICAL)

imagepy/app/loader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77
import os, sys, os.path as osp
88
from glob import glob
9-
from sciapp.action import Macros, Widget#, Report
9+
from sciapp.action import Macros, Widget, Report
1010
from .. import root_dir
1111
from .manager import DocumentManager, DictManager
1212
from codecs import open
@@ -23,9 +23,9 @@ def extend_plugins(path, lst, err):
2323
rst = []
2424
for i in lst:
2525
if isinstance(i, tuple) or i=='-': rst.append(i)
26-
elif i[-3:] == 'rpt': pass
27-
#pt = os.path.join(root_dir,path)
28-
#rst.append(Report(i[:-4], pt+'/'+i))
26+
elif i[-3:] == 'rpt':
27+
pt = os.path.join(root_dir,path)
28+
rst.append(Report(i[:-4], pt+'/'+i))
2929
elif i[-3:] in {'.md', '.mc', '.wf'}:
3030
p = os.path.join(os.path.join(root_dir, path), i).replace('\\','/')
3131
rst.append(Macros(i[:-3], ['Open>{"path":"%s"}'%p]))

imagepy/data/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[["uistyle", "imagepy", null], ["mea_style", {"color": [0, 0, 255], "fcolor": [255, 255, 255], "fill": false, "lw": 2, "tcolor": [0, 255, 0], "size": 12}, null], ["mark_style", {"color": [0, 255, 0], "fcolor": [255, 255, 255], "fill": false, "lw": 1, "tcolor": [255, 0, 0], "size": 8}, null], ["recent", ["C:/Users/54631/Desktop/\u6d77\u51b0\u62a5\u4ef7/testmacros.mc", "C:\\Users\\Administrator\\Downloads\\\u7d20\u6750\u2014\u8f66\u5934\\\u6d4b\u8bd5-JK1-\u52ff\u5220\\20170201\\In-20170201151126911-\u6842J73220-\u9ec4-qj-1.jpg", "C:/Users/Administrator/Desktop/imagepy/imagepy/plugins/demoplugin/menus/Demos/Macros Demo/Macros Gaussian Invert.mc", "DEM.mc"], null], ["roi_style", {"color": [255, 255, 0], "fcolor": [255, 255, 255], "fill": false, "lw": 1, "tcolor": [255, 255, 0], "size": 8}, null], ["language", "English", null]]
1+
[["language", "English", null], ["roi_style", {"color": [255, 255, 0], "fcolor": [255, 255, 255], "fill": false, "lw": 1, "tcolor": [255, 255, 0], "size": 8}, null], ["recent", ["C:/Users/54631/Desktop/\u6d77\u51b0\u62a5\u4ef7/testmacros.mc", "C:\\Users\\Administrator\\Downloads\\\u7d20\u6750\u2014\u8f66\u5934\\\u6d4b\u8bd5-JK1-\u52ff\u5220\\20170201\\In-20170201151126911-\u6842J73220-\u9ec4-qj-1.jpg", "C:/Users/Administrator/Desktop/imagepy/imagepy/plugins/demoplugin/menus/Demos/Macros Demo/Macros Gaussian Invert.mc", "DEM.mc"], null], ["mark_style", {"color": [0, 255, 0], "fcolor": [255, 255, 255], "fill": false, "lw": 1, "tcolor": [255, 0, 0], "size": 8}, null], ["mea_style", {"color": [0, 0, 255], "fcolor": [255, 255, 255], "fill": false, "lw": 2, "tcolor": [0, 255, 0], "size": 12}, null], ["uistyle", "imagepy", null]]

imagepy/menus/Analysis/statistic_plg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def run(self, ips, imgs, para = None):
9696
img = imgs[i] if msk is None else imgs[i][msk]
9797
maxv = img.max()
9898
if maxv==0:continue
99-
ct = np.histogram(img, maxv, [1,maxv+1])[0]
99+
ct = np.histogram(img, maxv+1, [0,maxv])[0]
100100
titles = ['slice','value','count']
101101
dt = [[i]*len(ct), list(range(maxv+1)), ct]
102102
if not para['slice']:

imagepy/menus/File/new_plg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99

1010
class Plugin(Free):
11-
title = 'New Image'
11+
title = 'New'
1212
para = {'name':'Undefined','width':300, 'height':300, 'type':'8-bit','slice':1}
1313
view = [(str, 'name', 'name', ''),
1414
(int, 'width', (1,10240), 0, 'width', 'pix'),
26.2 KB
Binary file not shown.

imagepy/menus/Process/Threshold/threshold_plgs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Niblack(Filter):
8181
(float, 'k', (0, 1), 2, 'offset', '')]
8282

8383
def run(self, ips, snap, img, para = None):
84-
if para['size']%2==0: return IPy.alert('size must be Odd')
84+
if para['size']%2==0: return self.app.alert('size must be Odd')
8585
img[:] = (snap>threshold_niblack(snap, para['size'], para['k']))*ips.range[1]
8686

8787
class Sauvola(Filter):
@@ -92,7 +92,7 @@ class Sauvola(Filter):
9292
(float, 'k', (0, 1), 2, 'offset', '')]
9393

9494
def run(self, ips, snap, img, para = None):
95-
if para['size']%2==0: return IPy.alert('size must be Odd')
95+
if para['size']%2==0: return self.app.alert('size must be Odd')
9696
img[:] = (snap>threshold_sauvola(snap, para['size'], para['k']))*ips.range[1]
9797

9898
plgs = [SimpleThreshold, Auto, '-', Local, Niblack, Sauvola, '-', Hysteresis]

sciapp/action/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from .plugin.mea_tools import *
55
from .plugin.shp_tools import *
66
from .plugin.roi_tools import *
7-
from .advanced import Filter, Free, Simple, Table, Macros, Widget, dataio
7+
from .advanced import Filter, Free, Simple, Table, Macros, Widget, dataio, Report

sciapp/action/advanced/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
from .table import Table
44
from .free import Free
55
from .macros import Macros
6-
from .widget import Widget
6+
from .widget import Widget
7+
from .report import Report

sciapp/action/advanced/report.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Thu Dec 29 01:48:23 2016
4+
@author: yxl
5+
"""
6+
import wx
7+
from sciapp import app
8+
from sciapp.action.advanced.dataio import ReaderManager
9+
# from imagepy.core.manager import ReaderManager, ViewerManager
10+
from sciwx.widgets.propertygrid import GridDialog
11+
from sciapp.util import xlreport
12+
from time import time
13+
import openpyxl as pyxl
14+
15+
class Report:
16+
def __init__(self, title, cont):
17+
self.title = title
18+
self.cont = cont
19+
20+
def __call__(self): return self
21+
22+
def runasyn(self, wb, info, key, para = None, callback = None):
23+
self.app.add_task(self)
24+
for i in para:
25+
if i in key and key[i][0] == 'img':
26+
ips = self.app.get_img(para[i])
27+
para[i] = ips if ips is None else ips.img
28+
29+
if i in key and key[i][0] == 'tab':
30+
tps = self.app.get_table(para[i])
31+
para[i] = tps if tps is None else tps.data
32+
33+
start = time()
34+
xlreport.fill_value(wb, info, para)
35+
wb.save(para['path'])
36+
self.app.info('%s: cost %.3fs'%(self.title, time()-start))
37+
self.app.remove_task(self)
38+
if callback!=None:callback()
39+
40+
def start(self, app, para=None, callafter=None):
41+
self.app = app
42+
wb = pyxl.load_workbook(self.cont)
43+
xlreport.repair(wb)
44+
info, key = xlreport.parse(wb)
45+
46+
if para is not None:
47+
return self.runasyn(wb, info, para, callafter)
48+
dialog = GridDialog(self.app, self.title, info, key)
49+
rst = dialog.ShowModal()
50+
para = dialog.GetValue()
51+
52+
dialog.Destroy()
53+
if rst != 5100: return
54+
filt = ['XLSX', 'xlsx', 'xlsx']
55+
path = self.app.get_path('Save..', filt, 'save')
56+
if not path: return
57+
para['path'] = path
58+
self.app.record_macros('{}>{}'.format(self.title, para))
59+
self.runasyn(wb, info, key, para, callafter)
60+
61+
def show_rpt(data, title):
62+
wx.CallAfter(Report(title, data).start)
63+
64+
# ViewerManager.add('rpt', show_rpt)
65+
def read_rpt(path): return path
66+
ReaderManager.add('rpt', read_rpt, tag='rpt')

0 commit comments

Comments
 (0)