Logo Search packages:      
Sourcecode: inkscape version File versions

static void sp_feSpecularLighting_set ( SPObject object,
unsigned int  key,
gchar const *  value 
) [static]

Sets a specific value in the SPFeSpecularLighting.

Definition at line 145 of file specularlighting.cpp.

{
    SPFeSpecularLighting *feSpecularLighting = SP_FESPECULARLIGHTING(object);
    gchar const *cend_ptr = NULL;
    gchar *end_ptr = NULL;
    switch(key) {
      /*DEAL WITH SETTING ATTRIBUTES HERE*/
//TODO test forbidden values
        case SP_ATTR_SURFACESCALE:
            end_ptr = NULL;
            if (value) {
                feSpecularLighting->surfaceScale = g_ascii_strtod(value, &end_ptr);
                if (end_ptr) {
                    feSpecularLighting->surfaceScale_set = TRUE;
                } else {
                    g_warning("feSpecularLighting: surfaceScale should be a number ... defaulting to 1");
                }

            }
            //if the attribute is not set or has an unreadable value
            if (!value || !end_ptr) {
                feSpecularLighting->surfaceScale = 1;
                feSpecularLighting->surfaceScale_set = FALSE;
            }
            if (feSpecularLighting->renderer) {
                feSpecularLighting->renderer->surfaceScale = feSpecularLighting->surfaceScale;
            }
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_SPECULARCONSTANT:
            end_ptr = NULL;
            if (value) {
                feSpecularLighting->specularConstant = g_ascii_strtod(value, &end_ptr);
                if (end_ptr && feSpecularLighting->specularConstant >= 0) {
                    feSpecularLighting->specularConstant_set = TRUE;
                } else {
                    end_ptr = NULL;
                    g_warning("feSpecularLighting: specularConstant should be a positive number ... defaulting to 1");
                }
            }
            if (!value || !end_ptr) {
                feSpecularLighting->specularConstant = 1;
                feSpecularLighting->specularConstant_set = FALSE;
            }
            if (feSpecularLighting->renderer) {
                feSpecularLighting->renderer->specularConstant = feSpecularLighting->specularConstant;
            }
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_SPECULAREXPONENT:
            end_ptr = NULL;
            if (value) {
                feSpecularLighting->specularExponent = g_ascii_strtod(value, &end_ptr);
                if (feSpecularLighting->specularExponent >= 1 && feSpecularLighting->specularExponent <= 128) {
                    feSpecularLighting->specularExponent_set = TRUE;
                } else {
                    end_ptr = NULL;
                    g_warning("feSpecularLighting: specularExponent should be a number in range [1, 128] ... defaulting to 1");
                }
            } 
            if (!value || !end_ptr) {
                feSpecularLighting->specularExponent = 1;
                feSpecularLighting->specularExponent_set = FALSE;
            }
            if (feSpecularLighting->renderer) {
                feSpecularLighting->renderer->specularExponent = feSpecularLighting->specularExponent;
            }
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_KERNELUNITLENGTH:
            //TODO kernelUnit
            //feSpecularLighting->kernelUnitLength.set(value);
            /*TODOif (feSpecularLighting->renderer) {
                feSpecularLighting->renderer->surfaceScale = feSpecularLighting->renderer;
            }
            */
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_PROP_LIGHTING_COLOR:
            cend_ptr = NULL;
            feSpecularLighting->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff);
            //if a value was read
            if (cend_ptr) {
                feSpecularLighting->lighting_color_set = TRUE;
            } else {
                //lighting_color already contains the default value
                feSpecularLighting->lighting_color_set = FALSE;
            }
            if (feSpecularLighting->renderer) {
                feSpecularLighting->renderer->lighting_color = feSpecularLighting->lighting_color;
            }
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        default:
            if (((SPObjectClass *) feSpecularLighting_parent_class)->set)
                ((SPObjectClass *) feSpecularLighting_parent_class)->set(object, key, value);
            break;
    }

}


Generated by  Doxygen 1.6.0   Back to index