ORSWidget¶
ChooseObjectAndNewName¶
-
class
ORSServiceClass.ORSWidget.chooseObjectAndNewName.chooseObjectAndNewName.ChooseObjectAndNewName(managedClass, parent=None, excludeObjectsGUIDS=[], getNewTitle=True, filterFunction=None, filterBox=None, defaultTitle='', isGeometry=False, selectedObj=None)¶ QDialog (floating) window containing a combo box to select an instance of the specified
ORSModel.ors.Managedsubclass and a title. The instances in the combo box can be filtered to exclude instances.Parameters: - managedClass (list of ORSModel.ors.Managed) – list of accepted subclasses of Managed
- parent (PyQt5.QtWidgets.QWidget) – parent widget
- excludeObjectsGUIDS (list of str) – GUIDs of the instances to exclude from the selection
- getNewTitle (bool) – if
True, the widget to specify a new title will be shown; ifFalse, that widget will be hidden. - filterFunction (function) – function receiving an instance of
ORSModel.ors.Managedin argument. If that function returnsTrue, this instance will be put as an available selection; if that function returnsFalse, this instance will not be available. Can beNone. - filterBox (ORSModel.ors.Box) – the box of an instance should match this argument to be available in the selection.
If
None, the shape of the instances is not considered.
Example:
@classmethod def selectAStructuredGrid(cls): # Instantiation and setup chooser = ChooseObjectAndNewName(managedClass=[StructuredGrid], parent=WorkingContext.getCurrentContextWindow()) chooser.setWindowTitle("Choose a StructuredGrid") chooser.setWindowFlags(Qt.Window | Qt.WindowTitleHint | Qt.WindowCloseButtonHint) # Execution and waiting for the user response if chooser.exec() == QDialog.Rejected: return None, '' # Getting the object selection and title aStructuredGridGUID = chooser.getObjectGUID() aStructuredGrid = orsObj(aStructuredGridGUID) aTitle = chooser.getTitle() return aStructuredGrid, aTitle
Source code example:
- Download the
file; - Put that file into a generic menu item extension folder;
- Start the application;
- Import a dataset;
- Create a ROI of the same shape as the dataset, where pixels included in the ROI are those representing the water;
- Create a ROI of the same shape as the dataset, where pixels included in the ROI are those representing the air;
- For the purpose of the demonstration, create another ROI of the same shape as the dataset and another ROI with a different shape (for example, by using the crop tool);
- Select the dataset and right-click on it to open the contextual menu. This menu will contain the menu item named Demo: ChooseObjectAndNewName. When clicking on that menu item, a popup will open to select the ROI representing the water. The available ROIs are only those not empty and having the same shape as the dataset. Select the ROI corresponding to the water and click on the button to accept the selection. Another popup will open to select the ROI representing the air. The available ROIs are only those not empty and having the same shape as the dataset, and note that the ROI specified for the water has been excluded. Select the ROI corresponding to the air and click on the button to accept the selection.
- The Hounsfield calibration is made on the dataset from these ROIs by adjusting the slope and offset.