コード例 #1
0
ファイル: offset.cpp プロジェクト: AakashDabas/inkscape
/**
 * Sets a specific value in the SPFeOffset.
 */
void SPFeOffset::set(unsigned int key, gchar const *value) {
    double read_num;

    switch(key) {
        case SP_ATTR_DX:
            read_num = value ? helperfns_read_number(value) : 0;

            if (read_num != this->dx) {
                this->dx = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_DY:
            read_num = value ? helperfns_read_number(value) : 0;

            if (read_num != this->dy) {
                this->dy = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
            
	/*DEAL WITH SETTING ATTRIBUTES HERE*/
        default:
        	SPFilterPrimitive::set(key, value);
            break;
    }
}
コード例 #2
0
ファイル: displacementmap.cpp プロジェクト: asitti/inkscape
/**
 * Sets a specific value in the SPFeDisplacementMap.
 */
void SPFeDisplacementMap::set(unsigned int key, gchar const *value) {
    int input;
    double read_num;
    FilterDisplacementMapChannelSelector read_selector;
    
    switch(key) {
	/*DEAL WITH SETTING ATTRIBUTES HERE*/
        case SP_ATTR_XCHANNELSELECTOR:
            read_selector = sp_feDisplacementMap_readChannelSelector(value);
            
            if (read_selector != this->xChannelSelector){
                this->xChannelSelector = read_selector;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_YCHANNELSELECTOR:
            read_selector = sp_feDisplacementMap_readChannelSelector(value);
            
            if (read_selector != this->yChannelSelector){
                this->yChannelSelector = read_selector;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_SCALE:
            read_num = value ? helperfns_read_number(value) : 0;
            
            if (read_num != this->scale) {
                this->scale = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_IN2:
            input = sp_filter_primitive_read_in(this, value);
            
            if (input != this->in2) {
                this->in2 = input;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        default:
        	SPFilterPrimitive::set(key, value);
            break;
    }
}
コード例 #3
0
ファイル: composite.cpp プロジェクト: loveq369/DoonSketch
/**
 * Sets a specific value in the SPFeComposite.
 */
static void
sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value)
{
    SPFeComposite *feComposite = SP_FECOMPOSITE(object);
    (void)feComposite;

    int input;
    FeCompositeOperator op;
    double k_n;
    switch(key) {
	/*DEAL WITH SETTING ATTRIBUTES HERE*/
        case SP_ATTR_OPERATOR:
            op = sp_feComposite_read_operator(value);
            if (op != feComposite->composite_operator) {
                feComposite->composite_operator = op;
                object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;

        case SP_ATTR_K1:
            k_n = value ? helperfns_read_number(value) : 0;
            if (k_n != feComposite->k1) {
                feComposite->k1 = k_n;
                if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
                    object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;

        case SP_ATTR_K2:
            k_n = value ? helperfns_read_number(value) : 0;
            if (k_n != feComposite->k2) {
                feComposite->k2 = k_n;
                if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
                    object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;

        case SP_ATTR_K3:
            k_n = value ? helperfns_read_number(value) : 0;
            if (k_n != feComposite->k3) {
                feComposite->k3 = k_n;
                if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
                    object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;

        case SP_ATTR_K4:
            k_n = value ? helperfns_read_number(value) : 0;
            if (k_n != feComposite->k4) {
                feComposite->k4 = k_n;
                if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
                    object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;

        case SP_ATTR_IN2:
            input = sp_filter_primitive_read_in(feComposite, value);
            if (input != feComposite->in2) {
                feComposite->in2 = input;
                object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;

        default:
            if (((SPObjectClass *) feComposite_parent_class)->set)
                ((SPObjectClass *) feComposite_parent_class)->set(object, key, value);
            break;
    }

}
コード例 #4
0
static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value)
{
    SPGlyph *glyph = SP_GLYPH(object);
    double number;
    glyphOrientation orient;
    glyphArabicForm form;

    switch (key) {
        case SP_ATTR_UNICODE:
            glyph->unicode.clear();
            if (value) glyph->unicode.append(value);
            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_GLYPH_NAME:
            glyph->glyph_name.clear();
            if (value) glyph->glyph_name.append(value);
            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_D:
            if (glyph->d) g_free(glyph->d);
            glyph->d = g_strdup(value);
            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_ORIENTATION:
            orient = sp_glyph_read_orientation(value);
            if (glyph->orientation != orient){
                glyph->orientation = orient;
                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_ARABIC_FORM:
            form = sp_glyph_read_arabic_form(value);
            if (glyph->arabic_form != form){
                glyph->arabic_form = form;
                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_LANG:
            if (glyph->lang) g_free(glyph->lang);
            glyph->lang = g_strdup(value);
            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
	case SP_ATTR_HORIZ_ADV_X:
            number = helperfns_read_number(value);
            if (number != glyph->horiz_adv_x){
                glyph->horiz_adv_x = number;
                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
	case SP_ATTR_VERT_ORIGIN_X:
            number = helperfns_read_number(value);
            if (number != glyph->vert_origin_x){
                glyph->vert_origin_x = number;
                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
	case SP_ATTR_VERT_ORIGIN_Y:
            number = helperfns_read_number(value);
            if (number != glyph->vert_origin_y){
                glyph->vert_origin_y = number;
                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
	case SP_ATTR_VERT_ADV_Y:
            number = helperfns_read_number(value);
            if (number != glyph->vert_adv_y){
                glyph->vert_adv_y = number;
                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
	default:
            if (((SPObjectClass *) (parent_class))->set) {
                ((SPObjectClass *) (parent_class))->set(object, key, value);
            }
            break;
    }
}
コード例 #5
0
/**
 * Sets a specific value in the SPFeConvolveMatrix.
 */
void SPFeConvolveMatrix::set(unsigned int key, gchar const *value) {
    double read_num;
    int read_int;
    bool read_bool;
    Inkscape::Filters::FilterConvolveMatrixEdgeMode read_mode;
   
    switch(key) {
	/*DEAL WITH SETTING ATTRIBUTES HERE*/
        case SP_ATTR_ORDER:
            this->order.set(value);
            
            //From SVG spec: If <orderY> is not provided, it defaults to <orderX>.
            if (this->order.optNumIsSet() == false) {
                this->order.setOptNumber(this->order.getNumber());
            }
            
            if (this->targetXIsSet == false) {
            	this->targetX = (int) floor(this->order.getNumber()/2);
            }
            
            if (this->targetYIsSet == false) {
            	this->targetY = (int) floor(this->order.getOptNumber()/2);
            }
            
            this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_KERNELMATRIX:
            if (value){
                this->kernelMatrixIsSet = true;
                this->kernelMatrix = helperfns_read_vector(value);
                
                if (! this->divisorIsSet) {
                    this->divisor = 0;
                    
                    for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) {
                        this->divisor += this->kernelMatrix[i];
                    }
                    
                    if (this->divisor == 0) {
                    	this->divisor = 1;
                    }
                }
                
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            } else {
                g_warning("For feConvolveMatrix you MUST pass a kernelMatrix parameter!");
            }
            break;
        case SP_ATTR_DIVISOR:
            if (value) { 
                read_num = helperfns_read_number(value);
                
                if (read_num == 0) {
                    // This should actually be an error, but given our UI it is more useful to simply set divisor to the default.
                    if (this->kernelMatrixIsSet) {
                        for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) {
                            read_num += this->kernelMatrix[i];
                        }
                    }
                    
                    if (read_num == 0) {
                    	read_num = 1;
                    }
                    
                    if (this->divisorIsSet || this->divisor!=read_num) {
                        this->divisorIsSet = false;
                        this->divisor = read_num;
                        this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
                    }
                } else if (!this->divisorIsSet || this->divisor!=read_num) {
                    this->divisorIsSet = true;
                    this->divisor = read_num;
                    this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
                }
            }
            break;
        case SP_ATTR_BIAS:
            read_num = 0;
            if (value) {
            	read_num = helperfns_read_number(value);
            }
            
            if (read_num != this->bias){
                this->bias = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_TARGETX:
            if (value) {
                read_int = (int) helperfns_read_number(value);
                
                if (read_int < 0 || read_int > this->order.getNumber()){
                    g_warning("targetX must be a value between 0 and orderX! Assuming floor(orderX/2) as default value.");
                    read_int = (int) floor(this->order.getNumber()/2.0);
                }
                
                this->targetXIsSet = true;
                
                if (read_int != this->targetX){
                    this->targetX = read_int;
                    this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
                }
            }
            break;
        case SP_ATTR_TARGETY:
            if (value) {
                read_int = (int) helperfns_read_number(value);
                
                if (read_int < 0 || read_int > this->order.getOptNumber()){
                    g_warning("targetY must be a value between 0 and orderY! Assuming floor(orderY/2) as default value.");
                    read_int = (int) floor(this->order.getOptNumber()/2.0);
                }
                
                this->targetYIsSet = true;
                
                if (read_int != this->targetY){
                    this->targetY = read_int;
                    this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
                }
            }
            break;
        case SP_ATTR_EDGEMODE:
            read_mode = sp_feConvolveMatrix_read_edgeMode(value);
            
            if (read_mode != this->edgeMode){
                this->edgeMode = read_mode;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_KERNELUNITLENGTH:
            this->kernelUnitLength.set(value);
            
            //From SVG spec: If the <dy> value is not specified, it defaults to the same value as <dx>.
            if (this->kernelUnitLength.optNumIsSet() == false) {
                this->kernelUnitLength.setOptNumber(this->kernelUnitLength.getNumber());
            }
            
            this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_PRESERVEALPHA:
            read_bool = helperfns_read_bool(value, false);
            
            if (read_bool != this->preserveAlpha){
                this->preserveAlpha = read_bool;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        default:
        	SPFilterPrimitive::set(key, value);
            break;
    }

}
コード例 #6
0
/**
 * Sets a specific value in the SPFeFuncNode.
 */
static void
sp_fefuncnode_set(SPObject *object, unsigned int key, gchar const *value)
{
    SPFeFuncNode *feFuncNode = SP_FEFUNCNODE(object);
    Inkscape::Filters::FilterComponentTransferType type;
    double read_num;
    switch(key) {
    case SP_ATTR_TYPE:
        type = sp_feComponenttransfer_read_type(value);
        if(type != feFuncNode->type) {
            feFuncNode->type = type;
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
        break;
    case SP_ATTR_TABLEVALUES:
        if (value) {
            feFuncNode->tableValues = helperfns_read_vector(value);
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
        break;
    case SP_ATTR_SLOPE:
        read_num = value ? helperfns_read_number(value) : 1;
        if (read_num != feFuncNode->slope) {
            feFuncNode->slope = read_num;
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
        break;
    case SP_ATTR_INTERCEPT:
        read_num = value ? helperfns_read_number(value) : 0;
        if (read_num != feFuncNode->intercept) {
            feFuncNode->intercept = read_num;
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
        break;
    case SP_ATTR_AMPLITUDE:
        read_num = value ? helperfns_read_number(value) : 1;
        if (read_num != feFuncNode->amplitude) {
            feFuncNode->amplitude = read_num;
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
        break;
    case SP_ATTR_EXPONENT:
        read_num = value ? helperfns_read_number(value) : 1;
        if (read_num != feFuncNode->exponent) {
            feFuncNode->exponent = read_num;
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
        break;
    case SP_ATTR_OFFSET:
        read_num = value ? helperfns_read_number(value) : 0;
        if (read_num != feFuncNode->offset) {
            feFuncNode->offset = read_num;
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
        break;
    default:
        if (((SPObjectClass *) feFuncNode_parent_class)->set)
            ((SPObjectClass *) feFuncNode_parent_class)->set(object, key, value);
        break;
    }
}
コード例 #7
0
/**
 * Sets a specific value in the SPFeFuncNode.
 */
void SPFeFuncNode::set(unsigned int key, gchar const *value) {
    Inkscape::Filters::FilterComponentTransferType type;
    double read_num;

    switch(key) {
        case SP_ATTR_TYPE:
            type = sp_feComponenttransfer_read_type(value);

            if(type != this->type) {
                this->type = type;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_TABLEVALUES:
            if (value){
                this->tableValues = helperfns_read_vector(value);
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_SLOPE:
            read_num = value ? helperfns_read_number(value) : 1;

            if (read_num != this->slope) {
                this->slope = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_INTERCEPT:
            read_num = value ? helperfns_read_number(value) : 0;

            if (read_num != this->intercept) {
                this->intercept = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_AMPLITUDE:
            read_num = value ? helperfns_read_number(value) : 1;

            if (read_num != this->amplitude) {
                this->amplitude = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_EXPONENT:
            read_num = value ? helperfns_read_number(value) : 1;

            if (read_num != this->exponent) {
                this->exponent = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_OFFSET:
            read_num = value ? helperfns_read_number(value) : 0;

            if (read_num != this->offset) {
                this->offset = read_num;
                this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        default:
        	SPObject::set(key, value);
            break;
    }
}
コード例 #8
0
ファイル: turbulence.cpp プロジェクト: loveq369/DoonSketch
/**
 * Sets a specific value in the SPFeTurbulence.
 */
static void
sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value)
{
    SPFeTurbulence *feTurbulence = SP_FETURBULENCE(object);
    (void)feTurbulence;

    int read_int;
    double read_num;
    bool read_bool;
    Inkscape::Filters::FilterTurbulenceType read_type;

    switch(key) {
	/*DEAL WITH SETTING ATTRIBUTES HERE*/

        case SP_ATTR_BASEFREQUENCY:
            feTurbulence->baseFrequency.set(value);
                //From SVG spec: If two <number>s are provided, the first number represents a base frequency in the X direction and the second value represents a base frequency in the Y direction. If one number is provided, then that value is used for both X and Y.
            if (feTurbulence->baseFrequency.optNumIsSet() == false)
                feTurbulence->baseFrequency.setOptNumber(feTurbulence->baseFrequency.getNumber());
            feTurbulence->updated = false;
            object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_NUMOCTAVES:
            read_int = value ? (int)floor(helperfns_read_number(value)) : 1;
            if (read_int != feTurbulence->numOctaves){
                feTurbulence->numOctaves = read_int;
                feTurbulence->updated = false;
                object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_SEED:
            read_num = value ? helperfns_read_number(value) : 0;
            if (read_num != feTurbulence->seed){
                feTurbulence->seed = read_num;
                feTurbulence->updated = false;
                object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_STITCHTILES:
            read_bool = sp_feTurbulence_read_stitchTiles(value);
            if (read_bool != feTurbulence->stitchTiles){
                feTurbulence->stitchTiles = read_bool;
                feTurbulence->updated = false;
                object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_TYPE:
            read_type = sp_feTurbulence_read_type(value);
            if (read_type != feTurbulence->type){
                feTurbulence->type = read_type;
                feTurbulence->updated = false;
                object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        default:
            if (((SPObjectClass *) feTurbulence_parent_class)->set)
                ((SPObjectClass *) feTurbulence_parent_class)->set(object, key, value);
            break;
    }

}