The plot-widgets itom1DQwtPlot and itom2DQwtPlot supports plotting of geometric primitives by user interaction and script language. This section will give a short introduction about ploting, read- /write-functions and the correspondig plots and the internal geometric element structure.
At last the evaluateGeomtrics-plugin for direct evaluation of geometric elements is introduced.
The plot functionality can be accessed by three different ways. The first way is the GUI based approach by which the user presses the “switch draw mode”-button in the button-bar of the plot. The button represents the current item to be plotted. The red X (“clear button”) will delete all geometric elements within the plot either drawn by hand or by script.
At the moment “itom” only supports “point”, “line”, “rectanlge” and “ellipse” but further items, e.g. “circle” and “polygons”, are in preparation. To draw an item simply click into the image space and left-click the mouse. In case of elements with at least more than a marker, you can now set the size of the element by setting the second point by left-clicking again. During plotting a green lined geometric element appears. After finishing the element color turns to the first inverse color of the current color palette with handles (diamonds or sqares) colored with the second inverse color of the current palette.
After creation the geometric elements can be editied by left-clicking one of the element handles which becomes high-lighted (squares) and moving the mouse. By pressing the “ctrl”-button during mouse-movement the element resize behavior will be changed depending on the element type. Lines will be changed to horizontal or vertical alignment. Rectangles and ellipses will be become squares or circles according to plot coordinates (x/y-space) and not pixel coordinates. To avoid confusion with plot aspect, a button for fixed axis aspect ratio (“1:1”) was added to the plot bar.
To allow more complex user interaction with scripts, e.g. script based element picking, the plot functionality can be started by script either blocking or non-blocking.
myImage = dataObject.randN([200, 200], 'float32')
[number, handle] = plot(myImage, "itom2dQwtPlot")
# Blocking access which return the values for a single point in myElement
# Structure will be dataObject([8, 1], 'float32') with [[idx], [type], [x], [y], [0], [0], [0],[0]]
myElement = dataObject()
handle.drawAndPickElements(101, myElement, 1)
# None blocking plot
# Structure will be dataObject([1, 11], 'float32') with [idx, type, x, y, 0, 0, 0, 0]
handle.call("userInteractionStart", 101, True, 1)
# --> Read out later after plot is finished
myGeometry = handle["geometricElements"]
The blocking code will wait until the selection is done or the selection was aborted by user and will than return the corresponding object. The non-blocking code will return directly. To access the geometric elements the corresponding “signal” for userInteractionDone should be used to noticed the end of the user interaction.
The geometric elements can also be set by script by calling the corresponding slot.
myImage = dataObject.randN([200, 200], 'float32')
[number, handle] = plot(myImage, "itom2dQwtPlot")
# Add the marker to the plot
# marker is filled according to marker style definition
marker = dataObject([8,1],'float32', data = [101.0, 1.0, 5.0, 6.0, 0.0, 0.0, 0.0, 0,0])
handle.call("plotMarkers", marker, "b", "")
# Delete all marker and than plot new marker
# marker is filled according to marker style definition
myGeometry = dataObject([1,11],'float32', data = [101.0, 1.0, 5.0, 6.0, 0.0, 0.0, 0.0, 0,0, 0.0, 0.0, 0.0])
handle["geometricElements"] = myGeometry
The geometric elements can be read any time using the property “geometricElements”.
# Reading geometric elements
myGeometry = handle["geometricElements"]
The object “myGeometry” consists of all geometric elements with in the plot. Each row corresponds to one geometric element while the parameters for each element are align column-wise. This kind of reading differs from the blocking-variant (“drawAndPickElements”). The blocking-variant returns only the data created during the current function call and ignores old geometric elements. In this case the elements are aligned column-wise. This means each column corresponds to on element while its data is stored along the rows. For the differernt definitions of the geometric elements see section “Indexing of Geometric Elements”.
The Qwt-plot widgets functions had to be updated. The Qwt-Widgets got the folling properties, respectivly setter- / getter-functions related to plotting:
In complete theses the functionality of the drawing interface, the following slots have been added to the widgets:
To register changes in the plot elements and finished user interactions, the following signals where implemented:
For the blocking connection the plotItem-class got the additional function drawAndPickElements(type, dataObject, count), see py:class:plotItem.
The definition of the geometric elements depends on the implementation. The “plotMarker” and its corresponding getter- / setter-function uses a Matlab orientated structure. The structure a dataObject with 8 rows and n columns where n depends on the number of elements. Points are defined by their location, while ellipses and rectangles are defined by their diagonal edges.
The “geometricElements”-property uses geometric elements in a more mathematical oriantated description. The dataObject stucture is defined as “float32” with n by 11 elements. Most setter functions also support “float32” elements. Each of the n rows corresponds to an elements (except polygon-shapes). The indexing follows the geometricPrimitive-struct in c++.
The geometricPrimitive is a struct within the c-Stuctur of the programm designed for exchanging the geometric elements from plots to other elements. The structur can be used rowise as dataObject or float32-lists
At the moment only tPoint, tLine, tEllipse and tRectangle are supported.
The cells contain:
All other values depends on the primitiv type and may change between each type.
This is a container to store geometric primitives. The enum tPrimitive of this file defines the geometric primitives for all plots.
Public Type
Discribes the different primtive types
Values:
! NoType for pick
! Multi point pick
! Element is tPoint or order to pick points
! Element is tLine or order to pick lines
! Element is tRectangle or order to pick rectangles
! Element is tSquare or order to pick squares
! Element is tEllipse or order to pick ellipses
! Element is tCircle or order to pick circles
! Element is tPolygon or order to pick polygon
! Element is readOnly
! Element can not be moved
! Element can not be moved
! Mask for the type space
The evaluateGeomtrics-widget is designed to load geometric definition stored in a float32 dataObject with a column-size of >10 elments and a row for each geometric element to display. Further more it allows the evaluation of geometric relations between the geometric primitives. See section Custom Designer Widgets for the widget description.
uiMeasureToolMain.py
demoPickPointsAndMarkers.py