Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto load ST on startup and version bump #64

Merged
merged 18 commits into from
Oct 11, 2023
Merged
Next Next commit
Open the plugin on startup
po09i committed Sep 11, 2023
commit 9db2bf905c699ae091a0a1e679c264642bffead6
4 changes: 1 addition & 3 deletions fsleyes_plugin_shimming_toolbox/components/run_component.py
Original file line number Diff line number Diff line change
@@ -14,9 +14,6 @@
from fsleyes_plugin_shimming_toolbox.events import EVT_RESULT, EVT_LOG
from fsleyes_plugin_shimming_toolbox.worker_thread import WorkerThread

# Load icon resources
play_icon = wx.Bitmap(os.path.join(__DIR_ST_PLUGIN_IMG__, 'play.png'), wx.BITMAP_TYPE_PNG)


class RunComponent(Component):
"""Component which contains input and run button.
@@ -57,6 +54,7 @@ def add_button_run(self):
"""Add the run button which will call the ``Shimming Toolbox`` CLI."""
button_run = wx.Button(self.panel, -1, label="Run", size=(85, 48))
button_run.Bind(wx.EVT_BUTTON, self.button_run_on_click)
play_icon = wx.Bitmap(os.path.join(__DIR_ST_PLUGIN_IMG__, 'play.png'), wx.BITMAP_TYPE_PNG)
button_run.SetBitmap(play_icon, dir=wx.LEFT)
self.sizer.Add(button_run, 0, wx.CENTRE)
self.sizer.AddSpacer(10)
10 changes: 10 additions & 0 deletions fsleyes_plugin_shimming_toolbox/st_plugin.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@

import fsleyes.controls.controlpanel as ctrlpanel
import fsleyes.views.canvaspanel as canvaspanel
import textwrap
import wx

from fsleyes_plugin_shimming_toolbox.tabs.b0shim_tab import B0ShimTab
@@ -26,6 +27,15 @@
from fsleyes_plugin_shimming_toolbox.tabs.fieldmap_tab import FieldMapTab
from fsleyes_plugin_shimming_toolbox.tabs.mask_tab import MaskTab

STLayout = textwrap.dedent(
"""
fsleyes.views.orthopanel.OrthoPanel
layout2|name=OrthoPanel 1;caption=Ortho View 1;state=67376064;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=-1;besth=-1;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1;notebookid=-1;transparent=255|dock_size(5,0,0)=22|
fsleyes.controls.orthotoolbar.OrthoToolBar,fsleyes.controls.overlaydisplaytoolbar.OverlayDisplayToolBar,fsleyes.controls.overlaylistpanel.OverlayListPanel,fsleyes.controls.locationpanel.LocationPanel,fsleyes_plugin_shimming_toolbox.st_plugin.STControlPanel;syncLocation=True,syncOverlayOrder=True,syncOverlayDisplay=True,syncOverlayVolume=True,movieRate=400,movieAxis=3;showCursor=True,bgColour=#000000ff,fgColour=#ffffffff,cursorColour=#00ff00ff,cursorGap=False,showColourBar=False,colourBarLocation=top,colourBarLabelSide=top-left,showXCanvas=True,showYCanvas=True,showZCanvas=True,showLabels=True,labelSize=12,layout=horizontal,xzoom=847.0127756479341,yzoom=847.0127756479341,zzoom=100.0
layout2|name=Panel;caption=;state=768;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=-1;besth=-1;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1;notebookid=-1;transparent=255|name=OrthoToolBar;caption=Ortho view toolbar;state=67382012;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=572;besth=35;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1;notebookid=-1;transparent=255|name=OverlayDisplayToolBar;caption=Display toolbar;state=67382012;dir=1;layer=11;row=0;pos=0;prop=100000;bestw=953;besth=56;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1;notebookid=-1;transparent=255|name=OverlayListPanel;caption=Overlay list;state=67373052;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=197;besth=80;minw=1;minh=1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=197;floath=99;notebookid=-1;transparent=255|name=LocationPanel;caption=Location;state=67373052;dir=3;layer=0;row=0;pos=1;prop=100000;bestw=391;besth=111;minw=1;minh=1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=391;floath=130;notebookid=-1;transparent=255|name=STControlPanel;caption=Shimming Toolbox;state=67373052;dir=1;layer=0;row=0;pos=0;prop=100000;bestw=600;besth=400;minw=1;minh=1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=600;floath=419;notebookid=-1;transparent=255|dock_size(5,0,0)=22|dock_size(3,0,0)=176|dock_size(1,10,0)=37|dock_size(1,11,0)=58|dock_size(1,0,0)=384|
"""
)


# We need to create a ctrlpanel.ControlPanel instance so that it can be recognized as a plugin by FSLeyes
# Class hierarchy: wx.Panel > fslpanel.FSLeyesPanel > ctrlpanel.ControlPanel
13 changes: 6 additions & 7 deletions fsleyes_plugin_shimming_toolbox/tabs/tab.py
Original file line number Diff line number Diff line change
@@ -8,13 +8,6 @@
from fsleyes_plugin_shimming_toolbox import __DIR_ST_PLUGIN_IMG__
from fsleyes_plugin_shimming_toolbox.components.input_component import InputComponent

# Load icon resources
rtd_logo = wx.Bitmap(os.path.join(__DIR_ST_PLUGIN_IMG__, 'RTD.png'), wx.BITMAP_TYPE_PNG)
# Load ShimmingToolbox logo saved as a png image, rescale it, and return it as a wx.Bitmap image.
st_logo = wx.Image(os.path.join(__DIR_ST_PLUGIN_IMG__, 'shimming_toolbox_logo.png'), wx.BITMAP_TYPE_PNG)
st_logo.Rescale(int(st_logo.GetWidth() * 0.2), int(st_logo.GetHeight() * 0.2), wx.IMAGE_QUALITY_HIGH)
st_logo = st_logo.ConvertToBitmap()


class Tab(wx.ScrolledWindow):
def __init__(self, parent, title, description):
@@ -57,12 +50,18 @@ def __init__(self, panel, description):
def create_sizer(self):
"""Create the left sizer containing generic Shimming Toolbox information."""
sizer = wx.BoxSizer(wx.VERTICAL)

# Load ShimmingToolbox logo saved as a png image, rescale it, and return it as a wx.Bitmap image.
st_logo = wx.Image(os.path.join(__DIR_ST_PLUGIN_IMG__, 'shimming_toolbox_logo.png'), wx.BITMAP_TYPE_PNG)
st_logo.Rescale(int(st_logo.GetWidth() * 0.2), int(st_logo.GetHeight() * 0.2), wx.IMAGE_QUALITY_HIGH)
st_logo = st_logo.ConvertToBitmap()
logo = wx.StaticBitmap(parent=self.panel, id=-1, bitmap=st_logo, pos=wx.DefaultPosition)
width = logo.Size[0]
sizer.Add(logo, flag=wx.SHAPED, proportion=1)
sizer.AddSpacer(10)

# Create a "Documentation" button that redirects towards https://shimming-toolbox.org/en/latest/
rtd_logo = wx.Bitmap(os.path.join(__DIR_ST_PLUGIN_IMG__, 'RTD.png'), wx.BITMAP_TYPE_PNG)
button_documentation = wx.Button(self.panel, label="Documentation")
button_documentation.Bind(wx.EVT_BUTTON, self.open_documentation_url)
button_documentation.SetBitmap(rtd_logo)
7 changes: 3 additions & 4 deletions fsleyes_plugin_shimming_toolbox/text_with_button.py
Original file line number Diff line number Diff line change
@@ -7,10 +7,6 @@
from fsleyes_plugin_shimming_toolbox import __DIR_ST_PLUGIN_IMG__
from fsleyes_plugin_shimming_toolbox.select import select_file, select_folder, select_from_overlay

# Load icon resources
info_icon = wx.Image(os.path.join(__DIR_ST_PLUGIN_IMG__, 'info-icon.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()
asterisk_icon = wx.Image(os.path.join(__DIR_ST_PLUGIN_IMG__, 'asterisk.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()


class TextWithButton:
"""Creates a button with an input text box.
@@ -102,6 +98,8 @@ def create(self):
for textctrl in self.textctrl_list:
text_with_button_box.Add(textctrl, 1, wx.ALIGN_LEFT | wx.LEFT, 10)
if self.required:
asterisk_icon = wx.Image(os.path.join(__DIR_ST_PLUGIN_IMG__, 'asterisk.png'),
wx.BITMAP_TYPE_PNG).ConvertToBitmap()
text_with_button_box.Add(wx.StaticBitmap(self.panel, bitmap=asterisk_icon), 0, wx.RIGHT, 7)

return text_with_button_box
@@ -280,6 +278,7 @@ def __init__(self, panel, bitmap, info_text):


def create_info_icon(panel, info_text=""):
info_icon = wx.Image(os.path.join(__DIR_ST_PLUGIN_IMG__, 'info-icon.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()
image = InfoIcon(panel, bitmap=info_icon, info_text=info_text)
image.Bind(wx.EVT_MOTION, on_info_icon_mouse_over)
return image