diff --git a/invesalius/constants.py b/invesalius/constants.py index 37005dcfb..de6822fe8 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -1020,6 +1020,7 @@ "mep_colormap": "Viridis", "gaussian_sharpness": 0.4, "gaussian_radius": 20, + "dimensions_size": 20, "bounds": None, "colormap_range_uv": {"min": 50, "low": 200, "mid": 600, "max": 1000}, } diff --git a/invesalius/data/visualization/mep_visualizer.py b/invesalius/data/visualization/mep_visualizer.py index f11ecbbe9..03fe26fb7 100644 --- a/invesalius/data/visualization/mep_visualizer.py +++ b/invesalius/data/visualization/mep_visualizer.py @@ -72,8 +72,6 @@ def __init__(self): self.is_navigating = False - self.dims_size = 20 - self._config_params = deepcopy(const.DEFAULT_MEP_CONFIG_PARAMS) self.__bind_events() self._LoadUserParameters() @@ -193,7 +191,7 @@ def InterpolateData(self): bounds = np.array(self._config_params["bounds"]) gaussian_sharpness = self._config_params["gaussian_sharpness"] gaussian_radius = self._config_params["gaussian_radius"] - dims_size = self.dims_size + dims_size = self._config_params["dimensions_size"] dims = np.array([dims_size, dims_size, dims_size]) box = vtkImageData() diff --git a/invesalius/gui/preferences.py b/invesalius/gui/preferences.py index d9887fbb7..6861d34dc 100644 --- a/invesalius/gui/preferences.py +++ b/invesalius/gui/preferences.py @@ -343,6 +343,29 @@ def InitMEPMapping(self, event): ] ) + # Dimensions size line + lbl_dims_size = wx.StaticText(bsizer_mep.GetStaticBox(), -1, _("Dimensions size:")) + self.spin_dims_size = wx.SpinCtrl(bsizer_mep.GetStaticBox(), -1, "", size=wx.Size(64, 23)) + self.spin_dims_size.Enable(1) + self.spin_dims_size.SetIncrement(5) + self.spin_dims_size.SetRange(10, 100) + self.spin_dims_size.SetValue(self.conf.get("dimensions_size")) + + self.spin_dims_size.Bind( + wx.EVT_TEXT, partial(self.OnSelectDimsSize, ctrl=self.spin_dims_size) + ) + self.spin_dims_size.Bind( + wx.EVT_SPINCTRL, partial(self.OnSelectDimsSize, ctrl=self.spin_dims_size) + ) + + line_dims_size = wx.BoxSizer(wx.HORIZONTAL) + line_dims_size.AddMany( + [ + (lbl_dims_size, 1, wx.EXPAND | wx.GROW | wx.TOP | wx.RIGHT | wx.LEFT, 0), + (self.spin_dims_size, 0, wx.ALL | wx.EXPAND | wx.GROW, 0), + ] + ) + # Select Colormap Line lbl_colormap = wx.StaticText(bsizer_mep.GetStaticBox(), -1, _("Select Colormap:")) lbl_colormap.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.BOLD)) @@ -477,6 +500,7 @@ def InitMEPMapping(self, event): (surface_sel_sizer, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5), (line_gaussian_radius, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5), (line_std_dev, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5), + (line_dims_size, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5), (colormap_sizer, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5), ] ) @@ -515,6 +539,11 @@ def OnSelectGaussianRadius(self, evt, ctrl): # Save the configuration self.session.SetConfig("mep_configuration", self.conf) + def OnSelectDimsSize(self, evt, ctrl): + self.conf["dimensions_size"] = ctrl.GetValue() + # Save the configuration + self.session.SetConfig("mep_configuration", self.conf) + def OnSelectColormapRange(self, evt, ctrl, key): self.conf["colormap_range_uv"][key] = ctrl.GetValue() self.session.SetConfig("mep_configuration", self.conf)