QColor LayerDrawer::color(const IRepresentation &rpr, double value, DrawerInterface::ColorValueMeaning cvm)
{
    if ( _activeAttribute != sUNDEF){
        VisualAttribute& attr = _visualProperties[_activeAttribute];
        if ( cvm ==DrawerInterface::cvmFRACTION){
            NumericRange numrange = attr.stretchRange();
            if ( !numrange.isValid()){
                numrange = attr.actualRange();
            }
            value = numrange.min() + numrange.distance() * value;

        }
        QColor clr = attr.value2color(value);
        return clr;
    }
    return QColor();
}
void NumericRepresentationSetter::prepare(VisualAttributeModel *vattrib, const IIlwisObject &obj, const ColumnDefinition &cdef)
{
    VisualAttributeEditor::prepare(vattrib, obj, cdef);

    if ( attribute()->layer() && attribute()->layer()->drawer()){
        QVariant actAttribute = attribute()->layer()->drawer()->attribute("activevisualattribute");
           if ( !actAttribute.isValid())
               return ;
        auto var = attribute()->layer()->drawer()->attribute("visualattribute|stretchrange|" + actAttribute.toString());
        NumericRange numrange = var.value<NumericRange>();
        if ( !numrange.isValid())
            return;

        NumericRange roundedRange = MathHelper::roundRange(numrange.min(), numrange.max());
        double tickValue = roundedRange.min();
        while(tickValue <= numrange.max()){
            _rprElements.push_back(new RepresentationElement(QString::number(tickValue),this));
            tickValue += roundedRange.resolution();
        }
        _rprElements.push_back(new RepresentationElement(QString::number(tickValue),this));

        emit rprNameChanged();
    }
}