Skip to content

Conversation

@ChristianWoegerbauer
Copy link
Contributor

Description

When using a slicer, a 1D plot opens. An action button has been added to the NavigationToolbar, which directly sends the 1D data to the fitting perspective. Furthermore, the 1D data is added to DataExplorer as a new datafile.

How Has This Been Tested?

LoadData -> e.g. src\sas\example_data\2d_data\SILIC010.DAT -> Send to Fitting -> Category e.g. Sphere, Model name e.g. Sphere -> Compute/Plot -> right_click on 2D plot and choose slicer -> 1D plot opens -> in NavigationToolbar a new action called "fitting" appears" -> when pressing the ActionButton the data is send to the fitting persepctive in a new tab and is added to DataExplorer as a new datafile.

Review Checklist:

[if using the editor, use [x] in place of [ ] to check a box]

Documentation (check at least one)

  • There is nothing that needs documenting
  • Documentation changes are in this PR
  • There is an issue open for the documentation (link?)

Installers

  • There is a chance this will affect the installers, if so
    • Windows installer (GH artifact) has been tested (installed and worked)
    • MacOSX installer (GH artifact) has been tested (installed and worked)
    • Wheels installer (GH artifact) has been tested (installed and worked)

Licensing (untick if necessary)

  • The introduced changes comply with SasView license (BSD 3-Clause)

"""
Add a new plot of self._data to the chart.
"""
self.lable_name = data.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it should be label instead of lable

Copy link
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments to consider on code clarity and methods location.

Comment on lines 26 to 27


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many empty lines

# This way all can be called with:
# self._actions['xxx']
custom_icon = QtGui.QIcon() # You can load an icon here if you want e.g., QtGui.QIcon("path/to/icon.png")
custom_action = QtGui.QAction(custom_icon, "Fitting", self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Fitting" is not descriptive enough, even with the tootlip. Please consider e.g. "Send to fitting" or even better "Freeze" since this is what the operation does.

Comment on lines 43 to 44
current_file_name: str = self.parent.lable_name
search_name = current_file_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary extra variable - please use only one

current_file_name: str = self.parent.lable_name
search_name = current_file_name

def find_name(model, target_name: str, column: int=0) -> int:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camelCase for method names in classes derived from QObject.

Comment on lines 53 to 61
model = self.parent.parent.model
row_index_parent, row_index_child = find_name(model, search_name)
data_dir = self.parent.parent.model.item(row_index_parent)
data = data_dir.child(row_index_child)
new_item = self.parent.parent.parent.filesWidget.cloneTheory(data)
model.beginResetModel()
model.appendRow(new_item)
model.endResetModel()
self.parent.parent.parent.filesWidget.sendData(None, [new_item])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing all these operations in PlotterBase, by referencing parent.parent.parent.... is smelly.
The best idea is to implement something like freezeDataWithName in DataExplorer, so no such object path traverse is taking place.
Here, you would just find out the name (line 43) and pass it to a signal, which DataExplorer would act on and do all these operations locally.


self.contextMenu = QtWidgets.QMenu(self)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar = CustomToolbar(self.canvas, self)#NavigationToolbar(self.canvas, self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove commented out code

self.parent.manager.updateModelFromPerspective(new_item)

items_for_fit.append(new_item)
self.new_item = new_item
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.new_item isn't used - please remove

Copy link
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now!

Copy link
Member

@butlerpd butlerpd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing the installer using a windows 11 machine I found the following issues. Some are questions of easthetics, some are "not great" but don't break and one is an error that I think must be addressed.

  1. while loading a 2D data, creating a 1D slice and then clicking the Send to fitting button on that works as advertised, if you startup sasview, load 1D data and then create a new graph with one of those then click Send to fitting this error appears (this is the case even if I start with a slicer.):
10:46:27 - ERROR: Traceback (most recent call last): File "sas\qtgui\MainWindow\DataExplorer.py", line 829, in freezeFromName AttributeError: 'NoneType' object has no attribute 'child'
  1. If you click on Send to fitting several times the same data is created several times. This may be the correct behavior in that the data in a given plot may change? but if it hasn't and the user forgets they have done it, the number of same data files piles up in the explorer?
  2. I note that because this is done in the navigator and the new action is right justified, the x,y cursor update is now to the left of that action (so no longer right justified itself). However on 2D data, which does not have the new action the cursor update still shows as right justified. Can the new action not just be left justified at the end of the existing actions? so to the right of the save icon?

Otherwise, sending data directly to fitting or inversion etc works as before. Also the new action on 1D data works for whatever analysis is loaded (including inversion and invariant) and fitting works .... once we get past the error described in one above.

Finally I note that after playing around a while we can get past that error and then Send to data works properly on all 1D plots as expected

@gonzalezma
Copy link
Contributor

Playing with this, I see that if one has a figure with several curves only the last one is sent to the data explorer (if not there) and loaded into a new FitPage. I agree this is the best behaviour, but I would suggest to inform about it using the tooltip (e.g. modify to say Send the last data set to Fitting). If the functionality is described in the documentation, update it also there.

@butlerpd
Copy link
Member

Thanks @ChristianWoegerbauer. I'm flying back tomorrow so it will likely be Thursday before I can look

Copy link
Member

@butlerpd butlerpd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ChristianWoegerbauer. This is a very nice feature addition and is working pretty smoothly IMO. I only found one minor issue besides what @gonzalezma identified.

Regarding the multiple curves in a single plot, I would think that sending all curves to the fit panel would be the expected behavior, each to its own tab. That would be consistent with how most of SasView works. However, if that is too much of an ask, I'm happy with Miguel's suggestion of adding that information to the tooltip and updating the documentation issue to indicate the need to include this.

The other issue I found is that if you send the single 1D data from the same plot several times, which could be legitimate if from a slicer for example where the slicer parameters are changed each time, 4 copies of that slicer are promoted to the DataExplorer, all having the same name with an additional _@### tacked on at the end to differentiate them. This part works.

However, the name sent to all fit tabs is exactly the same name which is the base name without the extra _@###. This makes it impossible to figure out which curve I am actually fitting. I am not sure why that is truncated from what is sent to the panel, but also I'm not sure where that _@### is coming from? is that being added in the code change? In general if a second data set is sent to the data explorer with the same name it gets given an identifier [1] for the second [2] for the third and so on. These do get copied to the title of the FitPage. Or is the file being sent to the FitPage directly and not using the DataExplorer machinery?

@ChristianWoegerbauer
Copy link
Contributor Author

ChristianWoegerbauer commented Nov 29, 2025

@butlerpd: The ending _@### is from the already existing cloneTheory function that i am using. The problem with _@### is also occurring when using the manual Send to Fitting button or with the "Freeze results" (rightclick on the data) . The root of the problem is somewhere else that i have not found yet. For some reason in the sendData routine (in the DataExplorer) the _@### is removed. It may be a feature instead? At least it is not an error from my side.

@butlerpd
Copy link
Member

butlerpd commented Dec 1, 2025

Thanks @ChristianWoegerbauer. Indeed, if the nomenclature problem comes from the underlying infrastructure you are using then it should definitely not be fixed here. It should be done in a separate PR. I'll try to make an issue for that.

Cool that you were able to make it work for all plots. I will try to test it sooon

Copy link
Member

@butlerpd butlerpd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality looks really slick now! I note that you clicked that "there is a issue to add the documentaion" I was not able to find that? can you give the issue number? This should be docummented in the Plotting Data/Models page of the documentation (under Working with SasView)

@ChristianWoegerbauer
Copy link
Contributor Author

@butlerpd due to the many changes i made since i created the issue, the content did not allign with the current state. I closed that issue and created a new one with the proper request (Issue: #3792)

@ChristianWoegerbauer ChristianWoegerbauer merged commit 9a0833a into main Dec 2, 2025
40 checks passed
@ChristianWoegerbauer ChristianWoegerbauer deleted the NavTool branch December 2, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants