Into

Modules

Documentation

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
(
  • 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.

(
  • int layer
  • float label
)

Return the class color corresponding the numberic label value label for the layer layer given as a parameter.

int
(
  • 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.

(
  • 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.

(
  • int layer
  • double label
)

Returns the defect color corresponding the parameter label for the the layer given as a parameter.

(
  • double label
)

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.

(
  • int layer
  • float label
)

Return the color corresponding the float type label value label for the layer layer given as a parameter.

(
  • float label
)

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.

(
  • const QList< double > & measurements
)

Returns the info text for the defect, whose numeric labels are given in the parameter measurements.

(
  • int layer
  • double label
)

Returns the info text corresponding the label for the layer given as a parameter.

int

Returns the current number of labeling layers.

(
  • int layer
)

Returns the layer name for the given layer.

Lists the user-visible names for layers.

( )
(
  • int layer
)

Returns the layer type for the layer given as a parameter.

int
(
  • 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.

void
(
  • int activeLayer
)

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.

static QList< QColor >
( )

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.

( )

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 layerType.

static double
( )

Returns the default label as double.

static QVector< QColor >
( )

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 defaultName.

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 T stored with the key itemName in the layer given as a parameter.

template<class T>
static QVector< T >
(
  • const QVariant & layer
  • const QList< T > & sourceList
  • const T & defaultValue
)

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 key as QVariant.

static double
(
  • const QVariant & layer
  • double defaultVal = 1.0
)

This function return the maximum value for the label in the given layer.

static double
(
  • const QVariant & layer
  • double defaultVal = 0.0
)

This function return the minimum value for the label in the given layer.

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
(
  • const QVariant & layer
  • double defaultVal = 0.1
)

This function return the resolution for the label value in the given layer.

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 T to the map item itemName into the layer given as a paramter.

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 type

    • LayerTypeFloat - 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, false is returned.

  • QColor classColor

    (
    • int layer
    • float label
    )

    Return the class color corresponding the numberic label value label for the layer layer given as a parameter.

    The type of the layer layer is 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 defaultDefectColor

    ()
    [inline]
  • QString defaultLayerName

    ()
    [inline]
  • QColor defectColor

    (
    • int layer
    • double label
    )

    Returns the defect color corresponding the parameter label for 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 label for the layer layer given as a parameter.

    The type of the layer layer is 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.

  • QString infoTextForDefect

    (
    • const QList< double > & measurements
    )

    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 in measurements, 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, where layerName is the layer name corresponding the parameter layer and label is 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, where layerName is the layer name corresponding to the parameter layer and class is the class corresponding to the parameter label. For example the result can be "Severity: Good".

    See more information about the layers in the documentation for the class PiiVisualTrainer.

  • 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.

  • QList< QVariant > layers

    ()
    [inline]
  • LayerType layerType

    (
    • int layer
    )

    Returns the layer type for the layer given 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.

  • void setDefaultDefectColor

    ()
    [inline]

    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),

  • void setDefaultLayerName

    ()
    [inline]

    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.

  • void setLayers

    ()

    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

    • type - layer type, currently either "float" or "class" (QString)

    • name - the user-visible name of the layer (QString)

    • opacity - strength of overlay coloring (int, 0 = transparent, 255 = opaque)

    • disabled - is layer disabled? (bool, default: false)

    Floating point layers

    • min - minimum value for a label (double, default: 0)

    • max - maximum value for a label (double, default: 1)

    • resolution - value resolution (double, default: 0.1)

    • startColor - gradient start color (QColor, default: transparent red)

    • endColor - gradient end color (QColor, default: saturated red)

    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

    ()
  • static bool checkIndexExistence

    ()
    [static]

    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, true is returned. Else false is returned from the function.

    There is also corresponding non-static function.

  • static QList< QColor > classColors

    ()
    [static]

    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 defaultColor is returned.

  • static int classIndexStatic

    ()
    [static]

    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 classIndex were 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().

  • static QList< int > classIndices

    ()
    [static]

    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.

  • static QStringList classNames

    ()
    [static]

    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.

  • static QString classNameStatic

    ()
    [static]

    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 defaultName is 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.

  • static QVariant createLayer

    [static]

    Creates and returns the layer of type layerType.

  • static double defaultNumericLabel

    ()
    [static]

    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.

  • static QVector< QColor > globalClassColors

    ()
    [static]

    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.

  • static bool hasKey

    ()
    [inline, static]

    Returns true if the key given as a parameter exists the given layer.

  • static QString labelAsString

    ()
    [static]

    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.

  • static QString layerName

    ()
    [static]

    This static function returns the name of the given layer, or the default layer name defaultName.

    The function does all the necessary validity checks.

  • static LayerType layerType

    ()
    [static]

    This static function returns the type of the given layer.

    In case of error LayerTypeUndefined is returned.

  • template<class T>

    static QList< T > list

    ()
    [inline, static]

    Return the list of the items of type T stored with the key itemName in 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.

  • template<class T>

    static QVector< T > makeVectorUsingGlobalInidices

    (
    • const QVariant & layer
    • const QList< T > & sourceList
    • const T & defaultValue
    )
    [inline, static]

    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.

  • static QVariant mapItem

    ()
    [static]

    This a helper function, which returns the value for key as QVariant.

    The function also checks, if the layer given as a parameter is a valid QVarianMap, if the key given as a parameter exists and if the value for the key is of type. In case of error an invalid QVariant is returned.

  • static double maxValue

    (
    • const QVariant & layer
    • double defaultVal = 1.0
    )
    [static]

    This function return the maximum value for the label in the given layer.

    If the layer data structure given as a parameter has an invalid format (e.g. the maximum value has not been specified), defaulVal is returned.

  • static double minValue

    (
    • const QVariant & layer
    • double defaultVal = 0.0
    )
    [static]

    This function return the minimum value for the label in the given layer.

    If the layer data structure given as a parameter has an invalid format (e.g. the minimum value has not been specified), defaulVal is returned.

  • static int realIndexStatic

    ()
    [static]

    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 classIndex were 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().

  • static void removeKey

    ()
    [static]

    Removes the key given as a parameter from the layer.

  • static double resolution

    (
    • const QVariant & layer
    • double defaultVal = 0.1
    )
    [static]

    This function return the resolution for the label value in the given layer.

    If the layer data structure given as a parameter has an invalid format (e.g. the resolution has not been specified), defaulVal is returned.

  • static void setClassColors

    ()
    [static]

    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.

  • static void setClassIndices

    ()
    [static]

    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.

  • static void setClassNames

    ()
    [static]

    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.

  • static void setLayerType

    ()
    [static]

    Set the layer type.

    The possible parameter can be LayerTypeFloat, LayerTypeClass, and LayerTypeUndefined.

  • template<class T>

    static void setList

    ()
    [inline, static]

    Set the list containing the items of type T to the map item itemName into 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.

  • static void setMapItem

    ()
    [static]

    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.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.