Ticket #8381 (closed: fixed)
Python driven controls for PeaksOverlay
Reported by: | Owen Arnold | Owned by: | Owen Arnold |
---|---|---|---|
Priority: | major | Milestone: | Release 3.1 |
Component: | Diffraction | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | #7512, #8428 | Tester: | Martyn Gigg |
Description (last modified by Owen Arnold) (diff)
There are three aims here prior to starting work on #7512
- Make it possible to control aspects of the Peaks Viewer on a per-peaks workspace basis via MantidPlot.
- Invert the control flow if necessary so that GUI controls can reflect demands made via python.
Duration 2 days.
Change History
comment:1 Changed 7 years ago by Owen Arnold
- Component changed from Framework to Diffraction
- Description modified (diff)
comment:2 Changed 7 years ago by Owen Arnold
- Status changed from new to inprogress
refs #8381. Start reverse control flow work.
I have also exposed peaks presenters via python. Seems to work ok thus far.
Changeset: 06af22949a942a5112024363782eb51adcb07a54
comment:3 Changed 7 years ago by Owen Arnold
refs #8381. Updating working both ways.
Selected aspects can be controlled both from the GUI and via python. Tests will need reworking.
Changeset: 47afb86768c71f6e15c0be8d1ebf7065f3037777
comment:4 Changed 7 years ago by Owen Arnold
refs #8381. Zoom to peak via python.
Zoom to a peak of a specific peaks presenter and select the corresponding row in the mini peaks workspace.
This is associated with a fix in what thread the code is executed upon. There is a Hack (marked HACK) in one of the presenters that will need fixing yet.
Changeset: e7f96794b4415f55271f14b5616f1ca71637adda
comment:5 Changed 7 years ago by Owen Arnold
refs #8381. Refactoring and fixes.
Changeset: 65d3bf218435f2b828814324180bf86063849c42
comment:6 Changed 7 years ago by Owen Arnold
refs #8381. Fix tests.
Some of the CompositePeaksPresenter tests were broken by the previous changes.
Changeset: 18da7e3884ba5c18e266c5fa6967b2ae513bdcb9
comment:7 Changed 7 years ago by Owen Arnold
refs #8381. Extend python tests and fix bug.
Bug was causing the 'Hide' button to get activated for no reason.
Changeset: 76c7eff2edda112b504dddf0edcab69863243260
comment:8 Changed 7 years ago by Owen Arnold
refs #8381. Change to American English.
Color is more consistent in the python API. Since this interface is being exposed via SIP. It makes sense to rename the colour functions.
Changeset: e7afc511a6c12713b69114c2d53b9e18b10fde5d
comment:9 Changed 7 years ago by Owen Arnold
refs #8381. Update sip documentation.
Changeset: ad8fc0184dc5425f3bb316a91def6d22d48f14d6
comment:10 Changed 7 years ago by Owen Arnold
refs #8381. Missing header file.
Changeset: 7f85072f5184707749fc599a2b11b217ed57a509
comment:11 Changed 7 years ago by Owen Arnold
refs #8381. Nested class causes problems on rhel6.
Changeset: 6ba9700b0e883dc727b0c5da053d2d766a6175f2
comment:12 Changed 7 years ago by Owen Arnold
refs #8381. Fix GCC warning.
Changeset: 495ff87bfc7d7ba5869bdbd89c90dbfb057fae82
comment:13 Changed 7 years ago by Owen Arnold
refs #8381. Fix windows error.
QObject defines no signals or slots, so its wrong to moc it.
Changeset: b0119daef004d7ce0b8be6202c36d601086a06ea
comment:14 Changed 7 years ago by Owen Arnold
Tester: You should already be familiar with the SC functionality of the SliceViewer before testing this ticket
This shows the new functionality in action.
def do(): import PyQt4.QtGui qLab = CreateMDWorkspace(Dimensions='3',EventType='MDEvent',Extents='-10,10,-10,10,-10,10',Names='Q_lab_x,Q_lab_y,Q_lab_z',Units='A,B,C') FakeMDEventData(InputWorkspace=qLab, PeakParams=[1000, 1, 1, 1, 1]) qLab = BinMD(InputWorkspace=qLab, AxisAligned=True, AlignedDim0="Q_lab_x,-10,10,100", AlignedDim1="Q_lab_y,-10,10,100", AlignedDim2="Q_lab_z,-10,10,100", IterateEvents="1", Parallel="0") SetSpecialCoordinates(qLab, 'Q (lab frame)') pathToInstrument = os.path.join(config["instrumentDefinition.directory"], 'CRISP_Definition.xml') # Note that the instrument doesn't matter. Choose a small one. instWS = LoadEmptyInstrument(Filename=pathToInstrument) # Only do this so that we can provide the parameter to CreatePeaksWorkspace pw = CreatePeaksWorkspace(InstrumentWorkspace=instWS, NumberOfPeaks=1) peak = pw.getPeak(0) peak.setQLabFrame(V3D(1, 1, 1), 1) svw = plotSlice(qLab.name(), slicepoint=[1, 1, 1], colormin=1, colormax=5000, colorscalelog=True) sv = svw.getSlicer() # Show the PeaksOverlays allPeaksPresenters = sv.setPeaksWorkspaces([pw.name()]) # Get first peaks presenter. peaksPresenter = allPeaksPresenters.getPeaksPresenter(pw.name()) # Set the Foreground Colour peaksPresenter.setForegroundColor(QtGui.QColor(255, 0, 0, 255)) # Zoom in on peak 2. peaksPresenter.zoomToPeak(0) do()
You should try this functionality out on some more complex examples, such as the SXD NaCl script.
comment:15 Changed 7 years ago by Owen Arnold
- Owner set to Owen Arnold
- Status changed from inprogress to verify
- Resolution set to fixed
comment:18 Changed 7 years ago by Russell Taylor
- Status changed from verify to reopened
- Resolution fixed deleted
The commit in comment:12 has left a compiler warning on RHEL6. Presumably it addressed a warning in a later version of GCC, but unfortunately you'll need to find another way so that the Red Hat one goes away as well.
comment:19 Changed 7 years ago by Owen Arnold
- Status changed from reopened to inprogress
refs #8381. Fix rhel6 warning.
Changeset: 2bd20ca1775bf4c42120f013b77f1b5612759f95
comment:20 Changed 7 years ago by Owen Arnold
- Status changed from inprogress to verify
- Resolution set to fixed
comment:21 Changed 7 years ago by Martyn Gigg
- Status changed from verify to verifying
- Tester set to Martyn Gigg
comment:22 Changed 7 years ago by Martyn Gigg
- Status changed from verifying to reopened
- Resolution fixed deleted
The functionality seems to work as expected.
One thing I tried was just passing a workspace to both sv.setPeaksWorkspaces([pw]) & allPeaksPresenters.getPeaksPresenter(pw) but it didn't work. You can this with plotSpectrum so I think it would be nice if you would be possible to accept a workspace reference as well as just a string name.
Would that be possible?
comment:23 Changed 7 years ago by Owen Arnold
- Status changed from reopened to inprogress
refs #8381. More robust and flexible input checks
More robust and flexible input checks. Perform any conversion if possible. Give errors on python side if bad inputs provided. Refactor code to use getWorkspaceNames from both modules.
Changeset: f3c7b4dfb1b7daf6784e7f1ae63d8be5d6778d10
comment:24 Changed 7 years ago by Owen Arnold
- Status changed from inprogress to verify
- Resolution set to fixed
comment:26 Changed 7 years ago by Martyn Gigg
- Status changed from verifying to closed
Merge remote-tracking branch 'origin/feature/8381_python_peaks_presenter'
Full changeset: 97f1fdc230522d748ed03f66e2c86573c1ca7670
comment:27 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 9226