classPiiLayerParser
#include <PiiLayerParser.h>
This class provides an interface for handling a data structure called a .
Description
Public types
|
enum
|
{
LayerTypeUndefined = 0x00, LayerTypeFloat = 0x01, LayerTypeClass = 0x02
}
The type of a layer can assume following values: |
Constructors and destructor
|
(
)
|
|
|
(
)
|
Public member functions
|
int
|
(
)
Returns the active layer. |
|
bool
|
(
Works exactly in the same way, than the corresponding static function, except the layer number is given as a parameter in stead of the layer itself. |
|
(
Return the class color corresponding the numberic label value |
|
|
int
|
(
Works exactly in the same way, than the corresponding static function |
|
(
Works exactly in the same way, than the corresponding static function |
|
|
(
)
|
|
|
(
Returns the defect color corresponding the parameter |
|
|
(
Similar to the previous function, except it uses the current active layer. |
|
|
int
|
Return the amount of enabled layers NOTE: Currently return the amount of all layers. |
|
(
Return the color corresponding the float type label value |
|
|
(
Works like the previous function, exept the color is calculated for the currently active layer. |
|
|
bool
|
Returns true if the key given as a parameter exists in the given layers. |
|
Returns the info text for the defect, whose numeric labels are given in the parameter |
|
|
(
Returns the info text corresponding the label for the layer given as a parameter. |
|
|
int
|
(
)
Returns the current number of labeling layers. |
|
(
Returns the layer name for the given layer. |
|
|
(
)
Lists the user-visible names for layers. |
|
|
(
)
|
|
|
(
Returns the layer type for the |
|
|
int
|
(
Works exactly in the same way, than the corresponding static function |
|
void
|
(
Sets the active layer. |
|
void
|
Sets the default color for the defects. |
|
void
|
Sets the default layer name for the layer parser. |
|
void
|
TODO: REVIEW THIS COMMENT BLOCK!! This function defines the selector layers. |
Static public member functions
|
static bool
|
Returns the the global class indices as an integer list for the layer given as a parameter. |
|
Returns the the class colors from the given layer as a list of QColor objects. |
|
|
static QColor
|
The function returns the class color corresponding to the either global or real index given as a parameter. |
|
static int
|
This static function returns the global index for the real class index given as a parameter, provided that the layer contains the item "classIndices". |
|
static QList< int >
|
Returns the the item "classIndices" of the layer as an integer list. |
|
static QStringList
|
Returns the the class names as a string list for the layer given as a parameter. |
|
static QString
|
The function returns the class name corresponding to the (real) index given as a parameter. |
|
static QString
|
The function returns the class name corresponding to the either global or real index given as a parameter. |
|
static void
|
Copies the map item corresponding the key given as a parameter from one layer to another. |
|
static QVariant
|
Creates and returns the layer of type |
|
static double
|
Returns the default label as double. |
|
Return the list of class colors for the layer. |
|
|
static bool
|
Returns true if the key given as a parameter exists the given layer. |
|
static QString
|
This static function returns the string to be shown in the user interface for the label given as a parameter. |
|
static QString
|
This static function returns the name of the given layer, or the default layer name |
|
static LayerType
|
This static function returns the type of the given layer. |
|
template<class T>
static QList< T >
|
Return the list of the items of type |
|
template<class T>
static QVector< T >
|
This function converts a list having "real" class indices to the vector having the "global" class indices. |
|
static QVariant
|
This a helper function, which returns the value for |
|
static double
|
This function return the maximum value for the label in the given |
|
static double
|
This function return the minimum value for the label in the given |
|
static int
|
This static function returns the real index for the global class index given as a parameter, provided that the layer contains the item "classIndices". |
|
static void
|
Removes the key given as a parameter from the layer. |
|
static double
|
This function return the resolution for the label value in the given |
|
static void
|
Sets the class colors to the given layer as a list of QColor objects. |
|
static void
|
Sets the global class indices as integers to the layer given as a parameter. |
|
static void
|
Sets the class names as a string list to the layer given as a parameter. |
|
static void
|
Set the layer type. |
|
template<class T>
static void
|
Set the list containing the items of type |
|
static void
|
The function sets the map item for the layer given as a parameter. |
Enumeration details
-
enum LayerType
The type of a layer can assume following values:
LayerTypeUndefined- undefined layer typeLayerTypeFloat- layer type "float"LayerTypeClass- layer type "class"
Function details
-
PiiLayerParser
() -
~PiiLayerParser
() -
int activeLayer
()[inline]Returns the active layer.
-
bool checkIndexExistence
(- int layer
- int index
Works exactly in the same way, than the corresponding static function, except the layer number is given as a parameter in stead of the layer itself.
If the layer number is out of bounds,
falseis returned. -
QColor classColor
(- int layer
- float label
Return the class color corresponding the numberic label value
labelfor the layerlayergiven as a parameter.The type of the layer
layeris expected to be "class". Otherwise the behaviour of the function is undefined. See more documentation about the layers in the documentation of the class PiiVisualTrainer. -
int classIndex
(- int layer
- int index
Works exactly in the same way, than the corresponding static function
classIndexStatic(), except the layer number is given as a parameter in stead of the layer itself.If the layer number is out of bounds, -1 is returned.
-
QString className
(- int layer
- int classIndex
Works exactly in the same way, than the corresponding static function
classNameStatic(), except the layer number is given as a parameter in stead of the layer itself.If the layer number is out of bounds, an empty string is returned.
-
-
-
QColor defectColor
(- int layer
- double label
Returns the defect color corresponding the parameter
labelfor the the layer given as a parameter.This function recognizes the layer type and based on the result of the recognition it calls the function classColor() or getFloatColor(). If the color information is not availabe, the default color, set by function setDefaultDefectColor(), is returned.
-
QColor defectColor
(- double label
Similar to the previous function, except it uses the current active layer.
It is recommended to use this function in stead the one introduced above, because this is faster.
-
int enabledLayerCount
()Return the amount of enabled layers NOTE: Currently return the amount of all layers.
-
QColor floatColor
(- int layer
- float label
Return the color corresponding the float type label value
labelfor the layerlayergiven as a parameter.The type of the layer
layeris expected to be "float". Otherwise the behaviour of the function is undefined. See more documentation about the layers in the documentation of the class PiiVisualTrainer. -
QColor floatColor
(- float label
Works like the previous function, exept the color is calculated for the currently active layer.
This function is also faster than the other function, because the cache is used to obtain the "min", "max", "startColor" and "endColor" values.
-
bool hasKey
Returns true if the key given as a parameter exists in the given layers.
-
Returns the info text for the defect, whose numeric labels are given in the parameter
measurements.The text is composed by looping through
measurements, calling the the function inforTextForLabel() for each label inmeasurements, and combining the results of the function calls by adding the line break character between them. See the documentation of the function infoTextForLabel() for more information. -
QString infoTextForLabel
(- int layer
- double label
Returns the info text corresponding the label for the layer given as a parameter.
The rules for composing the info text depend on the layer type. The rules are the following:
for the the floating point type layers the format is:
layerName + ": " + label, wherelayerNameis the layer name corresponding the parameterlayerandlabelis the second parameter of the function. For example the result can be "Formation index: 1.8".for the class type layer the format is:
layerName + ": " + class, wherelayerNameis the layer name corresponding to the parameterlayerandclassis the class corresponding to the parameterlabel. For example the result can be "Severity: Good".
-
int layerCount
()[inline]Returns the current number of labeling layers.
-
QString layerName
(- int layer
Returns the layer name for the given layer.
If the layer index is invalid or the layer doesn't contain any valid name, a default name is returned. The default name can be set with the function setDefaultLayerName(). If the default name has not been set, it is empty by default.
-
QStringList layerNames
()Lists the user-visible names for layers.
-
-
LayerType layerType
(- int layer
Returns the layer type for the
layergiven as a parameter.If the layer index is invalid, #LayerTypeUndefined is returned.
-
int realIndex
(- int layer
- int classIndex
Works exactly in the same way, than the corresponding static function
realIndexStatic(), except the layer number is given as a parameter in stead of the layer itself.If the layer number is out of bounds, -1 is returned.
-
void setActiveLayer
(- int activeLayer
Sets the active layer.
Some of the functions in PiiLayerParser expects that the active layer has been set. The default value for the active layer is 0.
-
Sets the default color for the defects.
The default color is used in the situations where the color information is not available. This is the case for example when the layer information has not been set or if when with the float type layer the value of the label is not between the minimum and maximum value. If the defaultDefectColor is not set, the default color is QColor(0,0,0),
-
Sets the default layer name for the layer parser.
The default default value is used in the situations where the layer name has not been set for the layer, or invalid layer index is used, when attempting to get the layer name. See the function
layerName()for the more information. If the default layer name has not been set, the default layer name is an empty string by default. -
TODO: REVIEW THIS COMMENT BLOCK!! This function defines the selector layers.
For each entry in this list, a new labeling layer is created. The configuration of the layer is stored as a map of name-value pairs. That is, each QVariant in this list is actually a QMap<QString, QVariant>. The configuration parameters depend on the type of the layer:
All layers
Floating point layers
Class label layers
classNames- class names (QStringList, default: "Good", "Defect")classColors- color codes (QList<QVariant>, QVariants must be QColors, default: arbitrary colors)
QMap<QString, QVariant> firstLayer; firstLayer["type"] = "float"; firstLayer["name"] = "Float layer"; firstLayer["max"] = 2; firstLayer["endColor"] = QColor(Qt::blue); //Note: Qt::blue is an int QMap<QString, QVariant> secondLayer; secondLayer["type"] = "class"; secondLayer["name"] = "Class name layer"; secondLayer["classNames"] = QStringList() << "Good" << "Fair" << "Poor"; secondLayer["classColors"] = QVariantList() << QColor(Qt::green) << QColor(Qt::yellow) << QColor(Qt::red); PiiLayerParser layerParser; layerParser.setLayers( QList<QVariant>() << firstLayer << secondLayer));
-
QStringList socketDescriptions
() -
Returns the the global class indices as an integer list for the layer given as a parameter.
The behavior of the function differs a little bit, depending wheter the layer contains the item "classIndices" or not. If the item "classIndices" exist, the return value of the function classIndices() is returned. Else the series of numbers, from zero to the amount of classes substracted by one, is returned. If for example the amount of classes in the layer were 5, and there are no "classIndices" item in the layer, the returned list will be [0, 1, 2, 3, 4].The indices are stored intenally in the layer as QVariantList, but the function makes the conversion from variant list to integer list. If the layer given as a parameter has not a valid QVariantMap structure, an empty list is returned. The function checks existence of the global index of the index given as a paramter for the given layer. It is assumed, that the type of the layer is LayerTypeClass. Else the behavior of the function is indeterminate.
The behavior of the function differs a little bit, depending wheter the layer contains the item "classIndices" or not. If the item "classIndices" exist, the function checks, if the list of class indices contains the index given as a parameter. Else the function checks, if the value of the index is greater than zero and less than amount of classes in the layer subtracted by one. If any of the conditions are met,
trueis returned. Elsefalseis returned from the function.There is also corresponding non-static function.
-
Returns the the class colors from the given layer as a list of QColor objects.
The class colors are stored internally in the layer as a list of QVariants, but this function takes care of making the conversion. If the layer given as a parameter has not a valid QVariantMap structure, an empty list is returned.
-
static QColor classColorStatic
[static]The function returns the class color corresponding to the either global or real index given as a parameter.
If the item "classIndices" exists in the layer given as a parameter, the global index is used. Else the real index is used. If a class with the given index doesn't exist, the value of the parameter
defaultColoris returned. -
This static function returns the global index for the real class index given as a parameter, provided that the layer contains the item "classIndices".
If for example the item "classIndices" contained the list {0,1,7,9}, and the value of the parameter
classIndexwere 2, 7 is returned. If the index given as a parameter is out of the bounds, -1 is returned.If the layer doesn't contain the item "classIndices", the number given as a parameter is returned.
It is assumed, that the type of the layer is "class". In other case, the behavior of the function is undefined.
There is also the corresponding non-static function
classIndex(). -
Returns the the item "classIndices" of the layer as an integer list.
The indices are stored intenally in the layer as QVariantList, but the function makes the conversion from variant list to integer list. If the layer given as a parameter has not a valid QVariantMap structure, an empty list is returned.
-
Returns the the class names as a string list for the layer given as a parameter.
If the layer given as a parameter has not a valid structure, an empty list is returned.
-
The function returns the class name corresponding to the (real) index given as a parameter.
If a class with the index doesn't exist, an empty string is returned. There is also corresponding non-static function, className().
-
static QString classNameStatic
[static]The function returns the class name corresponding to the either global or real index given as a parameter.
If the item "classIndices" exists in the layer given as a parameter, the global index is used. Else the real index is used. If a class with the given index doesn't exist, the value of the parameter
defaultNameis returned. -
static void copyMapItem
[static]Copies the map item corresponding the key given as a parameter from one layer to another.
If no item with the given key doesn't exist in the source layer, the item is not added in the destionation layer.
-
Creates and returns the layer of type
layerType. -
Returns the default label as double.
If the layer is of type "float", the result of function
minValue(), with the default value 0.0 is returned.If the layer type is "class", the result depends whether the layer contains the map item "classIndices". If the "classIndices" item is missing, 0.0 is returned. Else the class item having the smallest global index (== "classIndices") is returned.
The function can be used e.g. for initializing the outputs values, having labels as doubles, to some safe initial values.
-
Return the list of class colors for the layer.
The way how the list is formed, differs a little bit, depending whether the layer contain a "classIndices" item or not. If the layer doesn't contain a "classIndices" item, the list returned contains the colors in the same order than they were stored in the list. In the other case, the list returned contains the colors in the order defined by the "classIndices" list and also in the indices defined by the "classIndices" list. The length of the list returned is equal to the highest index stored in the "classInidices" list. The list returned can contain also indices that are not in "classIndices" list. Those indices will contain a default color given as a second parameter.
-
Returns true if the key given as a parameter exists the given layer.
-
This static function returns the string to be shown in the user interface for the label given as a parameter.
The apperance of the string depends on the type of the layer given as a parameter. If the layer type is "float", the label value given as a parmeter is just converted to string. If the layer type is "class" the class name corresponding to the label value is returned. In case of error an empty string is returned.
-
This static function returns the name of the given layer, or the default layer name
defaultName.The function does all the necessary validity checks.
-
This static function returns the type of the given layer.
In case of error LayerTypeUndefined is returned.
-
Return the list of the items of type
Tstored with the keyitemNamein the layer given as a parameter.It is assumed that the items has been stored in the layer as a QVariantList. The function makes the conversion from the QVariants to the type T.
-
This function converts a list having "real" class indices to the vector having the "global" class indices.
The global indices are picked from the "classIndices" field of the given as a parameter. The size of the vector is equal to the highest index in the "classIndices" list. The indices that are missing in the "classIndices" list, are filled with the default value given as a parameter.
If the "classInidices" field is missing, the return value contains the items in the same order than in just converted to vector.
-
This function return the maximum value for the label in the given
layer.If the
layerdata structure given as a parameter has an invalid format (e.g. the maximum value has not been specified),defaulValis returned. -
This function return the minimum value for the label in the given
layer.If the
layerdata structure given as a parameter has an invalid format (e.g. the minimum value has not been specified),defaulValis returned. -
This static function returns the real index for the global class index given as a parameter, provided that the layer contains the item "classIndices".
If for example the item "classIndices" contained the list {0,1,7,9}, and the value of the parameter
classIndexwere 7, 2 is returned. If the list of classIndices doesn't contain the number given as a parameter, -1 is returned.If the layer doesn't contain the item "classIndices", the number given as a parameter is returned.
It is assumed, that the type of the layer is "class". In other case, the behavior of the function is undefined.
There is also a corresponding non-static function
realIndex(). -
Removes the key given as a parameter from the layer.
-
This function return the resolution for the label value in the given
layer.If the
layerdata structure given as a parameter has an invalid format (e.g. the resolution has not been specified),defaulValis returned. -
Sets the class colors to the given layer as a list of QColor objects.
The function takes care of converting the list of QColors to the list of QVariants, how the colors are internally stored in the layer. If the layer given as a parameter contain not a valid QVariantMap structure, the list is not set.
-
Sets the global class indices as integers to the layer given as a parameter.
The function converts the integer list given as a paramaeter to variant list, and stores the list in the layer as list of variants. If the layer given as a parameter contain not a valid QVariantMap structure, the list is not set.
-
Sets the class names as a string list to the layer given as a parameter.
If the layer given as a parameter contain not a valid QVariantMap structure, list is not set.
-
Set the layer type.
The possible parameter can be
LayerTypeFloat,LayerTypeClass, andLayerTypeUndefined. -
template<class T>
static void setList
[inline, static]Set the list containing the items of type
Tto the map itemitemNameinto the layer given as a paramter.The items will be stored in the layer as a QVariantList. The function makes the conversion from the type T to QVariants.
-
The function sets the map item for the layer given as a parameter.
The layer given as a paramter should be a QVariantMap converted to the QVariant. The function checks that. In case of incorrect type, no changes are made in the layer.
Add a note
Not a single note added yet. Be the first, add yours.