diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-03-29 23:45:33 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-03-29 23:45:33 +0000 |
| commit | 3d7b1356600880a43e44e864cab08fff29cd23af (patch) | |
| tree | 52de4be4260970ec5f93d0eb80542dccb3425831 /src/filters | |
| parent | Various changes. (diff) | |
| download | inkscape-3d7b1356600880a43e44e864cab08fff29cd23af.tar.gz inkscape-3d7b1356600880a43e44e864cab08fff29cd23af.zip | |
Added "virtual pads" to
- SPFeFuncNode
- SPFeDistantLight
- SPFeMergeNode
- SPFePointLight
- SPFeSpotLight
- SPFilter
- SPFont
- SPGuide
Changes in SPItem and SPNamedView.
(bzr r11608.1.49)
Diffstat (limited to 'src/filters')
| -rw-r--r-- | src/filters/componenttransfer-funcnode.cpp | 172 | ||||
| -rw-r--r-- | src/filters/componenttransfer-funcnode.h | 25 | ||||
| -rw-r--r-- | src/filters/distantlight.cpp | 153 | ||||
| -rw-r--r-- | src/filters/distantlight.h | 24 | ||||
| -rw-r--r-- | src/filters/mergenode.cpp | 111 | ||||
| -rw-r--r-- | src/filters/mergenode.h | 25 | ||||
| -rw-r--r-- | src/filters/pointlight.cpp | 177 | ||||
| -rw-r--r-- | src/filters/pointlight.h | 24 | ||||
| -rw-r--r-- | src/filters/spotlight.cpp | 280 | ||||
| -rw-r--r-- | src/filters/spotlight.h | 24 |
10 files changed, 943 insertions, 72 deletions
diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 1a46ef01e..4299253f8 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -142,9 +142,19 @@ sp_fefuncnode_class_init(SPFeFuncNodeClass *klass) sp_object_class->update = sp_fefuncnode_update; } +CFeFuncNode::CFeFuncNode(SPFeFuncNode* funcnode) : CObject(funcnode) { + this->spfefuncnode = funcnode; +} + +CFeFuncNode::~CFeFuncNode() { +} + static void sp_fefuncnode_init(SPFeFuncNode *fefuncnode) { + fefuncnode->cfefuncnode = new CFeFuncNode(fefuncnode); + fefuncnode->cobject = fefuncnode->cfefuncnode; + fefuncnode->type = Inkscape::Filters::COMPONENTTRANSFER_TYPE_IDENTITY; //fefuncnode->tableValues = NULL; fefuncnode->slope = 1; @@ -159,13 +169,28 @@ sp_fefuncnode_init(SPFeFuncNode *fefuncnode) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_fefuncnode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ +//static void +//sp_fefuncnode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ // if (((SPObjectClass *) feFuncNode_parent_class)->build) { // ((SPObjectClass *) feFuncNode_parent_class)->build(object, document, repr); // } - // CPPIFY: todo +// //Read values of key attributes from XML nodes into object. +// object->readAttr( "type" ); +// object->readAttr( "tableValues" ); +// object->readAttr( "slope" ); +// object->readAttr( "intercept" ); +// object->readAttr( "amplitude" ); +// object->readAttr( "exponent" ); +// object->readAttr( "offset" ); +// +// +////is this necessary? +// document->addResource("fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ? +//} + +void CFeFuncNode::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::onBuild(document, repr); //Read values of key attributes from XML nodes into object. object->readAttr( "type" ); @@ -186,6 +211,19 @@ sp_fefuncnode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node */ static void sp_fefuncnode_release(SPObject *object) { +// //SPFeFuncNode *fefuncnode = SP_FEFUNCNODE(object); +// +// if ( object->document ) { +// // Unregister ourselves +// object->document->removeResource("fefuncnode", object); +// } +// +////TODO: release resources here + ((SPFeFuncNode*)object)->cfefuncnode->onRelease(); +} + +void CFeFuncNode::onRelease() { + SPFeFuncNode* object = this->spfefuncnode; //SPFeFuncNode *fefuncnode = SP_FEFUNCNODE(object); if ( object->document ) { @@ -224,6 +262,69 @@ static Inkscape::Filters::FilterComponentTransferType sp_feComponenttransfer_rea 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; +// } + ((SPFeFuncNode*)object)->cfefuncnode->onSet(key, value); +} + +void CFeFuncNode::onSet(unsigned int key, gchar const *value) { + SPFeFuncNode* object = this->spfefuncnode; + SPFeFuncNode *feFuncNode = SP_FEFUNCNODE(object); Inkscape::Filters::FilterComponentTransferType type; double read_num; @@ -277,8 +378,9 @@ sp_fefuncnode_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feFuncNode_parent_class)->set) - ((SPObjectClass *) feFuncNode_parent_class)->set(object, key, value); +// if (((SPObjectClass *) feFuncNode_parent_class)->set) +// ((SPObjectClass *) feFuncNode_parent_class)->set(object, key, value); + CObject::onSet(key, value); break; } } @@ -289,6 +391,25 @@ sp_fefuncnode_set(SPObject *object, unsigned int key, gchar const *value) static void sp_fefuncnode_update(SPObject *object, SPCtx *ctx, guint flags) { +// SPFeFuncNode *feFuncNode = SP_FEFUNCNODE(object); +// (void)feFuncNode; +// +// if (flags & SP_OBJECT_MODIFIED_FLAG) { +// /* do something to trigger redisplay, updates? */ +// //TODO +// //object->readAttr( "azimuth" ); +// //object->readAttr( "elevation" ); +// } +// +// if (((SPObjectClass *) feFuncNode_parent_class)->update) { +// ((SPObjectClass *) feFuncNode_parent_class)->update(object, ctx, flags); +// } + ((SPFeFuncNode*)object)->cfefuncnode->onUpdate(ctx, flags); +} + +void CFeFuncNode::onUpdate(SPCtx *ctx, guint flags) { + SPFeFuncNode* object = this->spfefuncnode; + SPFeFuncNode *feFuncNode = SP_FEFUNCNODE(object); (void)feFuncNode; @@ -299,9 +420,10 @@ sp_fefuncnode_update(SPObject *object, SPCtx *ctx, guint flags) //object->readAttr( "elevation" ); } - if (((SPObjectClass *) feFuncNode_parent_class)->update) { - ((SPObjectClass *) feFuncNode_parent_class)->update(object, ctx, flags); - } +// if (((SPObjectClass *) feFuncNode_parent_class)->update) { +// ((SPObjectClass *) feFuncNode_parent_class)->update(object, ctx, flags); +// } + CObject::onUpdate(ctx, flags); } /** @@ -310,6 +432,31 @@ sp_fefuncnode_update(SPObject *object, SPCtx *ctx, guint flags) static Inkscape::XML::Node * sp_fefuncnode_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { +// SPFeFuncNode *fefuncnode = SP_FEFUNCNODE(object); +// +// if (!repr) { +// repr = object->getRepr()->duplicate(doc); +// } +// +// (void)fefuncnode; +// /* +//TODO: I'm not sure what to do here... +// +// if (fefuncnode->azimuth_set) +// sp_repr_set_css_double(repr, "azimuth", fefuncnode->azimuth); +// if (fefuncnode->elevation_set) +// sp_repr_set_css_double(repr, "elevation", fefuncnode->elevation);*/ +// +// if (((SPObjectClass *) feFuncNode_parent_class)->write) { +// ((SPObjectClass *) feFuncNode_parent_class)->write(object, doc, repr, flags); +// } +// +// return repr; + return ((SPFeFuncNode*)object)->cfefuncnode->onWrite(doc, repr, flags); +} + +Inkscape::XML::Node* CFeFuncNode::onWrite(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeFuncNode* object = this->spfefuncnode; SPFeFuncNode *fefuncnode = SP_FEFUNCNODE(object); if (!repr) { @@ -325,9 +472,10 @@ TODO: I'm not sure what to do here... if (fefuncnode->elevation_set) sp_repr_set_css_double(repr, "elevation", fefuncnode->elevation);*/ - if (((SPObjectClass *) feFuncNode_parent_class)->write) { - ((SPObjectClass *) feFuncNode_parent_class)->write(object, doc, repr, flags); - } +// if (((SPObjectClass *) feFuncNode_parent_class)->write) { +// ((SPObjectClass *) feFuncNode_parent_class)->write(object, doc, repr, flags); +// } + CObject::onWrite(doc, repr, flags); return repr; } diff --git a/src/filters/componenttransfer-funcnode.h b/src/filters/componenttransfer-funcnode.h index d81e50577..55299b415 100644 --- a/src/filters/componenttransfer-funcnode.h +++ b/src/filters/componenttransfer-funcnode.h @@ -39,7 +39,12 @@ class SPFeFuncNode; class SPFeFuncNodeClass; -struct SPFeFuncNode : public SPObject { +class CFeFuncNode; + +class SPFeFuncNode : public SPObject { +public: + CFeFuncNode* cfefuncnode; + Inkscape::Filters::FilterComponentTransferType type; std::vector<double> tableValues; double slope; @@ -49,6 +54,24 @@ struct SPFeFuncNode : public SPObject { double offset; }; +class CFeFuncNode : public CObject { +public: + CFeFuncNode(SPFeFuncNode* funcnode); + virtual ~CFeFuncNode(); + + virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void onRelease(); + + virtual void onSet(unsigned int key, const gchar* value); + + virtual void onUpdate(SPCtx* ctx, unsigned int flags); + + virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + +private: + SPFeFuncNode* spfefuncnode; +}; + struct SPFeFuncNodeClass { SPObjectClass parent_class; }; diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 585afacf5..9255275d3 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -78,9 +78,19 @@ sp_fedistantlight_class_init(SPFeDistantLightClass *klass) sp_object_class->update = sp_fedistantlight_update; } +CFeDistantLight::CFeDistantLight(SPFeDistantLight* distantlight) : CObject(distantlight) { + this->spfedistantlight = distantlight; +} + +CFeDistantLight::~CFeDistantLight() { +} + static void sp_fedistantlight_init(SPFeDistantLight *fedistantlight) { + fedistantlight->cfedistantlight = new CFeDistantLight(fedistantlight); + fedistantlight->cobject = fedistantlight->cfedistantlight; + fedistantlight->azimuth = 0; fedistantlight->elevation = 0; fedistantlight->azimuth_set = FALSE; @@ -92,13 +102,24 @@ sp_fedistantlight_init(SPFeDistantLight *fedistantlight) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ +//static void +//sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ // if (((SPObjectClass *) feDistantLight_parent_class)->build) { // ((SPObjectClass *) feDistantLight_parent_class)->build(object, document, repr); // } - // CPPIFY: todo +// //Read values of key attributes from XML nodes into object. +// object->readAttr( "azimuth" ); +// object->readAttr( "elevation" ); +// +////is this necessary? +// document->addResource("fedistantlight", object); +//} + +void CFeDistantLight::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::onBuild(document, repr); + + SPFeDistantLight* object = this->spfedistantlight; //Read values of key attributes from XML nodes into object. object->readAttr( "azimuth" ); @@ -114,6 +135,20 @@ sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::N static void sp_fedistantlight_release(SPObject *object) { +// //SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); +// +// if ( object->document ) { +// // Unregister ourselves +// object->document->removeResource("fedistantlight", object); +// } +// +////TODO: release resources here + ((SPFeDistantLight*)object)->cfedistantlight->onRelease(); +} + +void CFeDistantLight::onRelease() { + SPFeDistantLight* object = this->spfedistantlight; + //SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); if ( object->document ) { @@ -130,6 +165,57 @@ sp_fedistantlight_release(SPObject *object) static void sp_fedistantlight_set(SPObject *object, unsigned int key, gchar const *value) { +// SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); +// gchar *end_ptr; +// switch (key) { +// case SP_ATTR_AZIMUTH: +// end_ptr =NULL; +// if (value) { +// fedistantlight->azimuth = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) { +// fedistantlight->azimuth_set = TRUE; +// } +// } +// if (!value || !end_ptr) { +// fedistantlight->azimuth_set = FALSE; +// fedistantlight->azimuth = 0; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_ELEVATION: +// end_ptr =NULL; +// if (value) { +// fedistantlight->elevation = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) { +// fedistantlight->elevation_set = TRUE; +// } +// } +// if (!value || !end_ptr) { +// fedistantlight->elevation_set = FALSE; +// fedistantlight->elevation = 0; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// default: +// // See if any parents need this value. +// if (((SPObjectClass *) feDistantLight_parent_class)->set) { +// ((SPObjectClass *) feDistantLight_parent_class)->set(object, key, value); +// } +// break; +// } + ((SPFeDistantLight*)object)->cfedistantlight->onSet(key, value); +} + +void CFeDistantLight::onSet(unsigned int key, gchar const *value) { + SPFeDistantLight* object = this->spfedistantlight; SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); gchar *end_ptr; switch (key) { @@ -171,9 +257,10 @@ sp_fedistantlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) feDistantLight_parent_class)->set) { - ((SPObjectClass *) feDistantLight_parent_class)->set(object, key, value); - } +// if (((SPObjectClass *) feDistantLight_parent_class)->set) { +// ((SPObjectClass *) feDistantLight_parent_class)->set(object, key, value); +// } + CObject::onSet(key, value); break; } } @@ -184,6 +271,23 @@ sp_fedistantlight_set(SPObject *object, unsigned int key, gchar const *value) static void sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags) { +// SPFeDistantLight *feDistantLight = SP_FEDISTANTLIGHT(object); +// (void)feDistantLight; +// +// if (flags & SP_OBJECT_MODIFIED_FLAG) { +// /* do something to trigger redisplay, updates? */ +// object->readAttr( "azimuth" ); +// object->readAttr( "elevation" ); +// } +// +// if (((SPObjectClass *) feDistantLight_parent_class)->update) { +// ((SPObjectClass *) feDistantLight_parent_class)->update(object, ctx, flags); +// } + ((SPFeDistantLight*)object)->cfedistantlight->onUpdate(ctx, flags); +} + +void CFeDistantLight::onUpdate(SPCtx *ctx, guint flags) { + SPFeDistantLight* object = this->spfedistantlight; SPFeDistantLight *feDistantLight = SP_FEDISTANTLIGHT(object); (void)feDistantLight; @@ -193,9 +297,10 @@ sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "elevation" ); } - if (((SPObjectClass *) feDistantLight_parent_class)->update) { - ((SPObjectClass *) feDistantLight_parent_class)->update(object, ctx, flags); - } +// if (((SPObjectClass *) feDistantLight_parent_class)->update) { +// ((SPObjectClass *) feDistantLight_parent_class)->update(object, ctx, flags); +// } + CObject::onUpdate(ctx, flags); } /** @@ -204,6 +309,27 @@ sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags) static Inkscape::XML::Node * sp_fedistantlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { +// SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); +// +// if (!repr) { +// repr = object->getRepr()->duplicate(doc); +// } +// +// if (fedistantlight->azimuth_set) +// sp_repr_set_css_double(repr, "azimuth", fedistantlight->azimuth); +// if (fedistantlight->elevation_set) +// sp_repr_set_css_double(repr, "elevation", fedistantlight->elevation); +// +// if (((SPObjectClass *) feDistantLight_parent_class)->write) { +// ((SPObjectClass *) feDistantLight_parent_class)->write(object, doc, repr, flags); +// } +// +// return repr; + return ((SPFeDistantLight*)object)->cfedistantlight->onWrite(doc, repr, flags); +} + +Inkscape::XML::Node* CFeDistantLight::onWrite(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeDistantLight* object = this->spfedistantlight; SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); if (!repr) { @@ -215,9 +341,10 @@ sp_fedistantlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape if (fedistantlight->elevation_set) sp_repr_set_css_double(repr, "elevation", fedistantlight->elevation); - if (((SPObjectClass *) feDistantLight_parent_class)->write) { - ((SPObjectClass *) feDistantLight_parent_class)->write(object, doc, repr, flags); - } +// if (((SPObjectClass *) feDistantLight_parent_class)->write) { +// ((SPObjectClass *) feDistantLight_parent_class)->write(object, doc, repr, flags); +// } + CObject::onWrite(doc, repr, flags); return repr; } diff --git a/src/filters/distantlight.h b/src/filters/distantlight.h index a68746334..de60cd507 100644 --- a/src/filters/distantlight.h +++ b/src/filters/distantlight.h @@ -29,7 +29,11 @@ class SPFeDistantLight; class SPFeDistantLightClass; -struct SPFeDistantLight : public SPObject { +class CFeDistantLight; + +class SPFeDistantLight : public SPObject { +public: + CFeDistantLight* cfedistantlight; /** azimuth attribute */ gfloat azimuth; @@ -39,6 +43,24 @@ struct SPFeDistantLight : public SPObject { guint elevation_set : 1; }; +class CFeDistantLight : public CObject { +public: + CFeDistantLight(SPFeDistantLight* distantlight); + virtual ~CFeDistantLight(); + + virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void onRelease(); + + virtual void onSet(unsigned int key, const gchar* value); + + virtual void onUpdate(SPCtx* ctx, unsigned int flags); + + virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + +private: + SPFeDistantLight* spfedistantlight; +}; + struct SPFeDistantLightClass { SPObjectClass parent_class; }; diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 1f57218c2..f5077b735 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -70,9 +70,19 @@ sp_feMergeNode_class_init(SPFeMergeNodeClass *klass) sp_object_class->update = sp_feMergeNode_update; } +CFeMergeNode::CFeMergeNode(SPFeMergeNode* mergenode) : CObject(mergenode) { + this->spfemergenode = mergenode; +} + +CFeMergeNode::~CFeMergeNode() { +} + static void sp_feMergeNode_init(SPFeMergeNode *feMergeNode) { + feMergeNode->cfemergenode = new CFeMergeNode(feMergeNode); + feMergeNode->cobject = feMergeNode->cfemergenode; + feMergeNode->input = Inkscape::Filters::NR_FILTER_SLOT_NOT_SET; } @@ -81,10 +91,15 @@ sp_feMergeNode_init(SPFeMergeNode *feMergeNode) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_feMergeNode_build(SPObject *object, SPDocument */*document*/, Inkscape::XML::Node */*repr*/) -{ - object->readAttr( "in" ); +//static void +//sp_feMergeNode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ +// object->readAttr( "in" ); +//} + +void CFeMergeNode::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + SPFeMergeNode* object = this->spfemergenode; + object->readAttr( "in" ); } /** @@ -93,10 +108,15 @@ sp_feMergeNode_build(SPObject *object, SPDocument */*document*/, Inkscape::XML:: static void sp_feMergeNode_release(SPObject *object) { - /* deal with our children and our selves here */ +// /* deal with our children and our selves here */ +// +// if (((SPObjectClass *) feMergeNode_parent_class)->release) +// ((SPObjectClass *) feMergeNode_parent_class)->release(object); + ((SPFeMergeNode*)object)->cfemergenode->onRelease(); +} - if (((SPObjectClass *) feMergeNode_parent_class)->release) - ((SPObjectClass *) feMergeNode_parent_class)->release(object); +void CFeMergeNode::onRelease() { + CObject::onRelease(); } /** @@ -105,6 +125,26 @@ sp_feMergeNode_release(SPObject *object) static void sp_feMergeNode_set(SPObject *object, unsigned int key, gchar const *value) { +// SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); +// SPFeMerge *parent = SP_FEMERGE(object->parent); +// +// if (key == SP_ATTR_IN) { +// int input = sp_filter_primitive_read_in(parent, value); +// if (input != feMergeNode->input) { +// feMergeNode->input = input; +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// } +// +// /* See if any parents need this value. */ +// if (((SPObjectClass *) feMergeNode_parent_class)->set) { +// ((SPObjectClass *) feMergeNode_parent_class)->set(object, key, value); +// } + ((SPFeMergeNode*)object)->cfemergenode->onSet(key, value); +} + +void CFeMergeNode::onSet(unsigned int key, gchar const *value) { + SPFeMergeNode* object = this->spfemergenode; SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); SPFeMerge *parent = SP_FEMERGE(object->parent); @@ -117,9 +157,10 @@ sp_feMergeNode_set(SPObject *object, unsigned int key, gchar const *value) } /* See if any parents need this value. */ - if (((SPObjectClass *) feMergeNode_parent_class)->set) { - ((SPObjectClass *) feMergeNode_parent_class)->set(object, key, value); - } +// if (((SPObjectClass *) feMergeNode_parent_class)->set) { +// ((SPObjectClass *) feMergeNode_parent_class)->set(object, key, value); +// } + CObject::onSet(key, value); } /** @@ -128,15 +169,30 @@ sp_feMergeNode_set(SPObject *object, unsigned int key, gchar const *value) static void sp_feMergeNode_update(SPObject *object, SPCtx *ctx, guint flags) { +// //SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); +// +// if (flags & SP_OBJECT_MODIFIED_FLAG) { +// object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// +// if (((SPObjectClass *) feMergeNode_parent_class)->update) { +// ((SPObjectClass *) feMergeNode_parent_class)->update(object, ctx, flags); +// } + ((SPFeMergeNode*)object)->cfemergenode->onUpdate(ctx, flags); +} + +void CFeMergeNode::onUpdate(SPCtx *ctx, guint flags) { + SPFeMergeNode* object = this->spfemergenode; //SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } - if (((SPObjectClass *) feMergeNode_parent_class)->update) { - ((SPObjectClass *) feMergeNode_parent_class)->update(object, ctx, flags); - } +// if (((SPObjectClass *) feMergeNode_parent_class)->update) { +// ((SPObjectClass *) feMergeNode_parent_class)->update(object, ctx, flags); +// } + CObject::onUpdate(ctx, flags); } /** @@ -145,6 +201,28 @@ sp_feMergeNode_update(SPObject *object, SPCtx *ctx, guint flags) static Inkscape::XML::Node * sp_feMergeNode_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { +// //SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); +// +// // Inkscape-only object, not copied during an "plain SVG" dump: +// if (flags & SP_OBJECT_WRITE_EXT) { +// if (repr) { +// // is this sane? +// //repr->mergeFrom(object->getRepr(), "id"); +// } else { +// repr = object->getRepr()->duplicate(doc); +// } +// } +// +// if (((SPObjectClass *) feMergeNode_parent_class)->write) { +// ((SPObjectClass *) feMergeNode_parent_class)->write(object, doc, repr, flags); +// } +// +// return repr; + return ((SPFeMergeNode*)object)->cfemergenode->onWrite(doc, repr, flags); +} + +Inkscape::XML::Node* CFeMergeNode::onWrite(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeMergeNode* object = this->spfemergenode; //SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); // Inkscape-only object, not copied during an "plain SVG" dump: @@ -157,9 +235,10 @@ sp_feMergeNode_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X } } - if (((SPObjectClass *) feMergeNode_parent_class)->write) { - ((SPObjectClass *) feMergeNode_parent_class)->write(object, doc, repr, flags); - } +// if (((SPObjectClass *) feMergeNode_parent_class)->write) { +// ((SPObjectClass *) feMergeNode_parent_class)->write(object, doc, repr, flags); +// } + CObject::onWrite(doc, repr, flags); return repr; } diff --git a/src/filters/mergenode.h b/src/filters/mergenode.h index 8352632a6..11ef03a93 100644 --- a/src/filters/mergenode.h +++ b/src/filters/mergenode.h @@ -24,10 +24,33 @@ class SPFeMergeNode; class SPFeMergeNodeClass; -struct SPFeMergeNode : public SPObject { +class CFeMergeNode; + +class SPFeMergeNode : public SPObject { +public: + CFeMergeNode* cfemergenode; + int input; }; +class CFeMergeNode : public CObject { +public: + CFeMergeNode(SPFeMergeNode* mergenode); + virtual ~CFeMergeNode(); + + virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void onRelease(); + + virtual void onSet(unsigned int key, const gchar* value); + + virtual void onUpdate(SPCtx* ctx, unsigned int flags); + + virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + +private: + SPFeMergeNode* spfemergenode; +}; + struct SPFeMergeNodeClass { SPObjectClass parent_class; }; diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index df513b393..74ee41301 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -78,9 +78,19 @@ sp_fepointlight_class_init(SPFePointLightClass *klass) sp_object_class->update = sp_fepointlight_update; } +CFePointLight::CFePointLight(SPFePointLight* pointlight) : CObject(pointlight) { + this->spfepointlight = pointlight; +} + +CFePointLight::~CFePointLight() { +} + static void sp_fepointlight_init(SPFePointLight *fepointlight) { + fepointlight->cfepointlight = new CFePointLight(fepointlight); + fepointlight->cobject = fepointlight->cfepointlight; + fepointlight->x = 0; fepointlight->y = 0; fepointlight->z = 0; @@ -95,13 +105,26 @@ sp_fepointlight_init(SPFePointLight *fepointlight) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ +//static void +//sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ // if (((SPObjectClass *) fePointLight_parent_class)->build) { // ((SPObjectClass *) fePointLight_parent_class)->build(object, document, repr); // } - // CPPIFY: todo +// //Read values of key attributes from XML nodes into object. +// object->readAttr( "x" ); +// object->readAttr( "y" ); +// object->readAttr( "z" ); +// +////is this necessary? +// document->addResource("fepointlight", object); +// ((SPFePointLight*)object)->cfepointlight->onBuild(document, repr); +//} + +void CFePointLight::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::onBuild(document, repr); + + SPFePointLight* object = this->spfepointlight; //Read values of key attributes from XML nodes into object. object->readAttr( "x" ); @@ -118,6 +141,19 @@ sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod static void sp_fepointlight_release(SPObject *object) { +// //SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); +// +// if ( object->document ) { +// // Unregister ourselves +// object->document->removeResource("fepointlight", object); +// } +// +////TODO: release resources here + ((SPFePointLight*)object)->cfepointlight->onRelease(); +} + +void CFePointLight::onRelease() { + SPFePointLight* object = this->spfepointlight; //SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); if ( object->document ) { @@ -134,6 +170,76 @@ sp_fepointlight_release(SPObject *object) static void sp_fepointlight_set(SPObject *object, unsigned int key, gchar const *value) { +// SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); +// gchar *end_ptr; +// switch (key) { +// case SP_ATTR_X: +// end_ptr = NULL; +// if (value) { +// fepointlight->x = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) { +// fepointlight->x_set = TRUE; +// } +// } +// if (!value || !end_ptr) { +// fepointlight->x = 0; +// fepointlight->x_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_Y: +// end_ptr = NULL; +// if (value) { +// fepointlight->y = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) { +// fepointlight->y_set = TRUE; +// } +// } +// if (!value || !end_ptr) { +// fepointlight->y = 0; +// fepointlight->y_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_Z: +// end_ptr = NULL; +// if (value) { +// fepointlight->z = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) { +// fepointlight->z_set = TRUE; +// } +// } +// if (!value || !end_ptr) { +// fepointlight->z = 0; +// fepointlight->z_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// default: +// // See if any parents need this value. +// if (((SPObjectClass *) fePointLight_parent_class)->set) { +// ((SPObjectClass *) fePointLight_parent_class)->set(object, key, value); +// } +// break; +// } + ((SPFePointLight*)object)->cfepointlight->onSet(key, value); +} + +void CFePointLight::onSet(unsigned int key, gchar const *value) { + SPFePointLight* object = this->spfepointlight; + SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); gchar *end_ptr; switch (key) { @@ -193,9 +299,10 @@ sp_fepointlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) fePointLight_parent_class)->set) { - ((SPObjectClass *) fePointLight_parent_class)->set(object, key, value); - } +// if (((SPObjectClass *) fePointLight_parent_class)->set) { +// ((SPObjectClass *) fePointLight_parent_class)->set(object, key, value); +// } + CObject::onSet(key, value); break; } } @@ -206,6 +313,25 @@ sp_fepointlight_set(SPObject *object, unsigned int key, gchar const *value) static void sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags) { +// SPFePointLight *fePointLight = SP_FEPOINTLIGHT(object); +// (void)fePointLight; +// +// if (flags & SP_OBJECT_MODIFIED_FLAG) { +// /* do something to trigger redisplay, updates? */ +// object->readAttr( "x" ); +// object->readAttr( "y" ); +// object->readAttr( "z" ); +// } +// +// if (((SPObjectClass *) fePointLight_parent_class)->update) { +// ((SPObjectClass *) fePointLight_parent_class)->update(object, ctx, flags); +// } + ((SPFePointLight*)object)->cfepointlight->onUpdate(ctx, flags); +} + +void CFePointLight::onUpdate(SPCtx *ctx, guint flags) { + SPFePointLight* object = this->spfepointlight; + SPFePointLight *fePointLight = SP_FEPOINTLIGHT(object); (void)fePointLight; @@ -216,9 +342,10 @@ sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "z" ); } - if (((SPObjectClass *) fePointLight_parent_class)->update) { - ((SPObjectClass *) fePointLight_parent_class)->update(object, ctx, flags); - } +// if (((SPObjectClass *) fePointLight_parent_class)->update) { +// ((SPObjectClass *) fePointLight_parent_class)->update(object, ctx, flags); +// } + CObject::onUpdate(ctx, flags); } /** @@ -227,6 +354,29 @@ sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags) static Inkscape::XML::Node * sp_fepointlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { +// SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); +// +// if (!repr) { +// repr = object->getRepr()->duplicate(doc); +// } +// +// if (fepointlight->x_set) +// sp_repr_set_css_double(repr, "x", fepointlight->x); +// if (fepointlight->y_set) +// sp_repr_set_css_double(repr, "y", fepointlight->y); +// if (fepointlight->z_set) +// sp_repr_set_css_double(repr, "z", fepointlight->z); +// +// if (((SPObjectClass *) fePointLight_parent_class)->write) { +// ((SPObjectClass *) fePointLight_parent_class)->write(object, doc, repr, flags); +// } +// +// return repr; + return ((SPFePointLight*)object)->cfepointlight->onWrite(doc, repr, flags); +} + +Inkscape::XML::Node* CFePointLight::onWrite(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFePointLight* object = this->spfepointlight; SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); if (!repr) { @@ -240,9 +390,10 @@ sp_fepointlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: if (fepointlight->z_set) sp_repr_set_css_double(repr, "z", fepointlight->z); - if (((SPObjectClass *) fePointLight_parent_class)->write) { - ((SPObjectClass *) fePointLight_parent_class)->write(object, doc, repr, flags); - } +// if (((SPObjectClass *) fePointLight_parent_class)->write) { +// ((SPObjectClass *) fePointLight_parent_class)->write(object, doc, repr, flags); +// } + CObject::onWrite(doc, repr, flags); return repr; } diff --git a/src/filters/pointlight.h b/src/filters/pointlight.h index c0b272021..0617c2333 100644 --- a/src/filters/pointlight.h +++ b/src/filters/pointlight.h @@ -29,7 +29,11 @@ class SPFePointLight; class SPFePointLightClass; -struct SPFePointLight : public SPObject { +class CFePointLight; + +class SPFePointLight : public SPObject { +public: + CFePointLight* cfepointlight; /** x coordinate of the light source */ gfloat x; @@ -44,6 +48,24 @@ struct SPFePointLight : public SPObject { //other fields }; +class CFePointLight : public CObject { +public: + CFePointLight(SPFePointLight* pointlight); + virtual ~CFePointLight(); + + virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void onRelease(); + + virtual void onSet(unsigned int key, const gchar* value); + + virtual void onUpdate(SPCtx* ctx, unsigned int flags); + + virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + +private: + SPFePointLight* spfepointlight; +}; + struct SPFePointLightClass { SPObjectClass parent_class; }; diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 7ea4a0e7b..49cec8267 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -78,9 +78,19 @@ sp_fespotlight_class_init(SPFeSpotLightClass *klass) sp_object_class->update = sp_fespotlight_update; } +CFeSpotLight::CFeSpotLight(SPFeSpotLight* spotlight) : CObject(spotlight) { + this->spfespotlight = spotlight; +} + +CFeSpotLight::~CFeSpotLight() { +} + static void sp_fespotlight_init(SPFeSpotLight *fespotlight) { + fespotlight->cfespotlight = new CFeSpotLight(fespotlight); + fespotlight->cobject = fespotlight->cfespotlight; + fespotlight->x = 0; fespotlight->y = 0; fespotlight->z = 0; @@ -105,13 +115,31 @@ sp_fespotlight_init(SPFeSpotLight *fespotlight) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ +//static void +//sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ // if (((SPObjectClass *) feSpotLight_parent_class)->build) { // ((SPObjectClass *) feSpotLight_parent_class)->build(object, document, repr); // } - // CPPIFY: todo +// //Read values of key attributes from XML nodes into object. +// object->readAttr( "x" ); +// object->readAttr( "y" ); +// object->readAttr( "z" ); +// object->readAttr( "pointsAtX" ); +// object->readAttr( "pointsAtY" ); +// object->readAttr( "pointsAtZ" ); +// object->readAttr( "specularExponent" ); +// object->readAttr( "limitingConeAngle" ); +// +////is this necessary? +// document->addResource("fespotlight", object); +// ((SPFeSpotLight*)object)->cfespotlight->onBuild(document, repr); +//} + +void CFeSpotLight::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::onBuild(document, repr); + + SPFeSpotLight* object = this->spfespotlight; //Read values of key attributes from XML nodes into object. object->readAttr( "x" ); @@ -133,6 +161,19 @@ sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node static void sp_fespotlight_release(SPObject *object) { +// //SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); +// +// if ( object->document ) { +// // Unregister ourselves +// object->document->removeResource("fespotlight", object); +// } +// +////TODO: release resources here + ((SPFeSpotLight*)object)->cfespotlight->onRelease(); +} + +void CFeSpotLight::onRelease() { + SPFeSpotLight* object = this->spfespotlight; //SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); if ( object->document ) { @@ -149,6 +190,159 @@ sp_fespotlight_release(SPObject *object) static void sp_fespotlight_set(SPObject *object, unsigned int key, gchar const *value) { +// SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); +// gchar *end_ptr; +// +// switch (key) { +// case SP_ATTR_X: +// end_ptr = NULL; +// if (value) { +// fespotlight->x = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->x_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->x = 0; +// fespotlight->x_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_Y: +// end_ptr = NULL; +// if (value) { +// fespotlight->y = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->y_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->y = 0; +// fespotlight->y_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_Z: +// end_ptr = NULL; +// if (value) { +// fespotlight->z = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->z_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->z = 0; +// fespotlight->z_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_POINTSATX: +// end_ptr = NULL; +// if (value) { +// fespotlight->pointsAtX = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->pointsAtX_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->pointsAtX = 0; +// fespotlight->pointsAtX_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_POINTSATY: +// end_ptr = NULL; +// if (value) { +// fespotlight->pointsAtY = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->pointsAtY_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->pointsAtY = 0; +// fespotlight->pointsAtY_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_POINTSATZ: +// end_ptr = NULL; +// if (value) { +// fespotlight->pointsAtZ = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->pointsAtZ_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->pointsAtZ = 0; +// fespotlight->pointsAtZ_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_SPECULAREXPONENT: +// end_ptr = NULL; +// if (value) { +// fespotlight->specularExponent = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->specularExponent_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->specularExponent = 1; +// fespotlight->specularExponent_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// case SP_ATTR_LIMITINGCONEANGLE: +// end_ptr = NULL; +// if (value) { +// fespotlight->limitingConeAngle = g_ascii_strtod(value, &end_ptr); +// if (end_ptr) +// fespotlight->limitingConeAngle_set = TRUE; +// } +// if(!value || !end_ptr) { +// fespotlight->limitingConeAngle = 90; +// fespotlight->limitingConeAngle_set = FALSE; +// } +// if (object->parent && +// (SP_IS_FEDIFFUSELIGHTING(object->parent) || +// SP_IS_FESPECULARLIGHTING(object->parent))) { +// object->parent->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); +// } +// break; +// default: +// // See if any parents need this value. +// if (((SPObjectClass *) feSpotLight_parent_class)->set) { +// ((SPObjectClass *) feSpotLight_parent_class)->set(object, key, value); +// } +// break; +// } + ((SPFeSpotLight*)object)->cfespotlight->onSet(key, value); +} + +void CFeSpotLight::onSet(unsigned int key, gchar const *value) { + SPFeSpotLight* object = this->spfespotlight; + SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); gchar *end_ptr; @@ -291,9 +485,10 @@ sp_fespotlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) feSpotLight_parent_class)->set) { - ((SPObjectClass *) feSpotLight_parent_class)->set(object, key, value); - } +// if (((SPObjectClass *) feSpotLight_parent_class)->set) { +// ((SPObjectClass *) feSpotLight_parent_class)->set(object, key, value); +// } + CObject::onSet(key, value); break; } } @@ -304,6 +499,30 @@ sp_fespotlight_set(SPObject *object, unsigned int key, gchar const *value) static void sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags) { +// SPFeSpotLight *feSpotLight = SP_FESPOTLIGHT(object); +// (void)feSpotLight; +// +// if (flags & SP_OBJECT_MODIFIED_FLAG) { +// /* do something to trigger redisplay, updates? */ +// object->readAttr( "x" ); +// object->readAttr( "y" ); +// object->readAttr( "z" ); +// object->readAttr( "pointsAtX" ); +// object->readAttr( "pointsAtY" ); +// object->readAttr( "pointsAtZ" ); +// object->readAttr( "specularExponent" ); +// object->readAttr( "limitingConeAngle" ); +// } +// +// if (((SPObjectClass *) feSpotLight_parent_class)->update) { +// ((SPObjectClass *) feSpotLight_parent_class)->update(object, ctx, flags); +// } + ((SPFeSpotLight*)object)->cfespotlight->onUpdate(ctx, flags); +} + +void CFeSpotLight::onUpdate(SPCtx *ctx, guint flags) { + SPFeSpotLight* object = this->spfespotlight; + SPFeSpotLight *feSpotLight = SP_FESPOTLIGHT(object); (void)feSpotLight; @@ -319,9 +538,10 @@ sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "limitingConeAngle" ); } - if (((SPObjectClass *) feSpotLight_parent_class)->update) { - ((SPObjectClass *) feSpotLight_parent_class)->update(object, ctx, flags); - } +// if (((SPObjectClass *) feSpotLight_parent_class)->update) { +// ((SPObjectClass *) feSpotLight_parent_class)->update(object, ctx, flags); +// } + CObject::onUpdate(ctx, flags); } /** @@ -330,6 +550,39 @@ sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags) static Inkscape::XML::Node * sp_fespotlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { +// SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); +// +// if (!repr) { +// repr = object->getRepr()->duplicate(doc); +// } +// +// if (fespotlight->x_set) +// sp_repr_set_css_double(repr, "x", fespotlight->x); +// if (fespotlight->y_set) +// sp_repr_set_css_double(repr, "y", fespotlight->y); +// if (fespotlight->z_set) +// sp_repr_set_css_double(repr, "z", fespotlight->z); +// if (fespotlight->pointsAtX_set) +// sp_repr_set_css_double(repr, "pointsAtX", fespotlight->pointsAtX); +// if (fespotlight->pointsAtY_set) +// sp_repr_set_css_double(repr, "pointsAtY", fespotlight->pointsAtY); +// if (fespotlight->pointsAtZ_set) +// sp_repr_set_css_double(repr, "pointsAtZ", fespotlight->pointsAtZ); +// if (fespotlight->specularExponent_set) +// sp_repr_set_css_double(repr, "specularExponent", fespotlight->specularExponent); +// if (fespotlight->limitingConeAngle_set) +// sp_repr_set_css_double(repr, "limitingConeAngle", fespotlight->limitingConeAngle); +// +// if (((SPObjectClass *) feSpotLight_parent_class)->write) { +// ((SPObjectClass *) feSpotLight_parent_class)->write(object, doc, repr, flags); +// } +// +// return repr; + return ((SPFeSpotLight*)object)->cfespotlight->onWrite(doc, repr, flags); +} + +Inkscape::XML::Node* CFeSpotLight::onWrite(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeSpotLight* object = this->spfespotlight; SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); if (!repr) { @@ -353,9 +606,10 @@ sp_fespotlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X if (fespotlight->limitingConeAngle_set) sp_repr_set_css_double(repr, "limitingConeAngle", fespotlight->limitingConeAngle); - if (((SPObjectClass *) feSpotLight_parent_class)->write) { - ((SPObjectClass *) feSpotLight_parent_class)->write(object, doc, repr, flags); - } +// if (((SPObjectClass *) feSpotLight_parent_class)->write) { +// ((SPObjectClass *) feSpotLight_parent_class)->write(object, doc, repr, flags); +// } + CObject::onWrite(doc, repr, flags); return repr; } diff --git a/src/filters/spotlight.h b/src/filters/spotlight.h index 6e2463c08..9cc5bd958 100644 --- a/src/filters/spotlight.h +++ b/src/filters/spotlight.h @@ -29,7 +29,11 @@ class SPFeSpotLight; class SPFeSpotLightClass; -struct SPFeSpotLight : public SPObject { +class CFeSpotLight; + +class SPFeSpotLight : public SPObject { +public: + CFeSpotLight* cfespotlight; /** x coordinate of the light source */ gfloat x; @@ -58,6 +62,24 @@ struct SPFeSpotLight : public SPObject { //other fields }; +class CFeSpotLight : public CObject { +public: + CFeSpotLight(SPFeSpotLight* spotlight); + virtual ~CFeSpotLight(); + + virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void onRelease(); + + virtual void onSet(unsigned int key, const gchar* value); + + virtual void onUpdate(SPCtx* ctx, unsigned int flags); + + virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + +private: + SPFeSpotLight* spfespotlight; +}; + struct SPFeSpotLightClass { SPObjectClass parent_class; }; |
