summaryrefslogtreecommitdiffstats
path: root/src/sp-lpe-item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp-lpe-item.cpp')
-rw-r--r--src/sp-lpe-item.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index 89a2658c8..b7e4ee4a9 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -197,8 +197,8 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape
/**
* returns true when LPE was successful.
*/
-bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) {
- if (!lpeitem) {
+bool SPLPEItem::performPathEffect(SPCurve *curve) {
+ if (!this) {
return false;
}
@@ -206,15 +206,15 @@ bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) {
return false;
}
- if (lpeitem->hasPathEffect() && lpeitem->pathEffectsEnabled()) {
- for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
+ if (this->hasPathEffect() && this->pathEffectsEnabled()) {
+ for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it)
{
LivePathEffectObject *lpeobj = (*it)->lpeobject;
if (!lpeobj) {
/** \todo Investigate the cause of this.
* For example, this happens when copy pasting an object with LPE applied. Probably because the object is pasted while the effect is not yet pasted to defs, and cannot be found.
*/
- g_warning("sp_lpe_item_perform_path_effect - NULL lpeobj in list!");
+ g_warning("SPLPEItem::performPathEffect - NULL lpeobj in list!");
return false;
}
Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
@@ -222,7 +222,7 @@ bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) {
/** \todo Investigate the cause of this.
* Not sure, but I think this can happen when an unknown effect type is specified...
*/
- g_warning("sp_lpe_item_perform_path_effect - lpeobj with invalid lpe in the stack!");
+ g_warning("SPLPEItem::performPathEffect - lpeobj with invalid lpe in the stack!");
return false;
}
@@ -234,8 +234,8 @@ bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) {
}
// Groups have their doBeforeEffect called elsewhere
- if (!SP_IS_GROUP(lpeitem)) {
- lpe->doBeforeEffect(lpeitem);
+ if (!SP_IS_GROUP(this)) {
+ lpe->doBeforeEffect(this);
}
try {
@@ -366,95 +366,95 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem)
}
}
-void sp_lpe_item_add_path_effect(SPLPEItem *lpeitem, gchar *value, bool reset)
+void SPLPEItem::addPathEffect(gchar *value, bool reset)
{
if (value) {
// Apply the path effects here because in the casse of a group, lpe->resetDefaults
// needs that all the subitems have their effects applied
- sp_lpe_item_update_patheffect(lpeitem, false, true);
+ sp_lpe_item_update_patheffect(this, false, true);
// Disable the path effects while preparing the new lpe
- sp_lpe_item_enable_path_effects(lpeitem, false);
+ sp_lpe_item_enable_path_effects(this, false);
// Add the new reference to the list of LPE references
HRefList hreflist;
- for (PathEffectList::const_iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
+ for (PathEffectList::const_iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it)
{
hreflist.push_back( std::string((*it)->lpeobject_href) );
}
hreflist.push_back( std::string(value) );
std::string hrefs = hreflist_write_svg(hreflist);
- lpeitem->getRepr()->setAttribute("inkscape:path-effect", hrefs.c_str());
+ this->getRepr()->setAttribute("inkscape:path-effect", hrefs.c_str());
// make sure there is an original-d for paths!!!
- sp_lpe_item_create_original_path_recursive(lpeitem);
+ sp_lpe_item_create_original_path_recursive(this);
- LivePathEffectObject *lpeobj = lpeitem->path_effect_list->back()->lpeobject;
+ LivePathEffectObject *lpeobj = this->path_effect_list->back()->lpeobject;
if (lpeobj && lpeobj->get_lpe()) {
Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
// Ask the path effect to reset itself if it doesn't have parameters yet
if (reset) {
// has to be called when all the subitems have their lpes applied
- lpe->resetDefaults(lpeitem);
+ lpe->resetDefaults(this);
}
// perform this once when the effect is applied
- lpe->doOnApply(SP_LPE_ITEM(lpeitem));
+ lpe->doOnApply(this);
// indicate that all necessary preparations are done and the effect can be performed
lpe->setReady();
}
//Enable the path effects now that everything is ready to apply the new path effect
- sp_lpe_item_enable_path_effects(lpeitem, true);
+ sp_lpe_item_enable_path_effects(this, true);
// Apply the path effect
- sp_lpe_item_update_patheffect(lpeitem, true, true);
+ sp_lpe_item_update_patheffect(this, true, true);
}
}
-void sp_lpe_item_add_path_effect(SPLPEItem *lpeitem, LivePathEffectObject * new_lpeobj)
+void SPLPEItem::addPathEffect(LivePathEffectObject * new_lpeobj)
{
const gchar * repr_id = new_lpeobj->getRepr()->attribute("id");
gchar *hrefstr = g_strdup_printf("#%s", repr_id);
- sp_lpe_item_add_path_effect(lpeitem, hrefstr, false);
+ this->addPathEffect(hrefstr, false);
g_free(hrefstr);
}
-void sp_lpe_item_remove_current_path_effect(SPLPEItem *lpeitem, bool keep_paths)
+void SPLPEItem::removeCurrentPathEffect(bool keep_paths)
{
- Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem);
+ Inkscape::LivePathEffect::LPEObjectReference* lperef = this->getCurrentLPEReference();
if (!lperef)
return;
- PathEffectList new_list = *lpeitem->path_effect_list;
+ PathEffectList new_list = *this->path_effect_list;
new_list.remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list
std::string r = patheffectlist_write_svg(new_list);
if (!r.empty()) {
- lpeitem->getRepr()->setAttribute("inkscape:path-effect", r.c_str());
+ this->getRepr()->setAttribute("inkscape:path-effect", r.c_str());
} else {
- lpeitem->getRepr()->setAttribute("inkscape:path-effect", NULL);
+ this->getRepr()->setAttribute("inkscape:path-effect", NULL);
}
if (!keep_paths) {
- sp_lpe_item_cleanup_original_path_recursive(lpeitem);
+ sp_lpe_item_cleanup_original_path_recursive(this);
}
}
-void sp_lpe_item_remove_all_path_effects(SPLPEItem *lpeitem, bool keep_paths)
+void SPLPEItem::removeAllPathEffects(bool keep_paths)
{
- lpeitem->getRepr()->setAttribute("inkscape:path-effect", NULL);
+ this->getRepr()->setAttribute("inkscape:path-effect", NULL);
if (!keep_paths) {
- sp_lpe_item_cleanup_original_path_recursive(lpeitem);
+ sp_lpe_item_cleanup_original_path_recursive(this);
}
}
void SPLPEItem::downCurrentPathEffect()
{
- Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(this);
+ Inkscape::LivePathEffect::LPEObjectReference* lperef = getCurrentLPEReference();
if (!lperef)
return;
@@ -475,7 +475,7 @@ void SPLPEItem::downCurrentPathEffect()
void SPLPEItem::upCurrentPathEffect()
{
- Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(this);
+ Inkscape::LivePathEffect::LPEObjectReference* lperef = getCurrentLPEReference();
if (!lperef)
return;
@@ -577,11 +577,11 @@ SPLPEItem::getPathEffectOfType(int type)
return NULL;
}
-void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt)
+void SPLPEItem::editNextParamOncanvas(SPDesktop *dt)
{
- Inkscape::LivePathEffect::LPEObjectReference *lperef = sp_lpe_item_get_current_lpereference(lpeitem);
+ Inkscape::LivePathEffect::LPEObjectReference *lperef = this->getCurrentLPEReference();
if (lperef && lperef->lpeobject && lperef->lpeobject->get_lpe()) {
- lperef->lpeobject->get_lpe()->editNextParamOncanvas(lpeitem, dt);
+ lperef->lpeobject->get_lpe()->editNextParamOncanvas(this, dt);
}
}
@@ -658,18 +658,18 @@ PathEffectList const SPLPEItem::getEffectList() const
return *path_effect_list;
}
-Inkscape::LivePathEffect::LPEObjectReference* sp_lpe_item_get_current_lpereference(SPLPEItem *lpeitem)
+Inkscape::LivePathEffect::LPEObjectReference* SPLPEItem::getCurrentLPEReference()
{
- if (!lpeitem->current_path_effect && !lpeitem->path_effect_list->empty()) {
- sp_lpe_item_set_current_path_effect(lpeitem, lpeitem->path_effect_list->back());
+ if (!this->current_path_effect && !this->path_effect_list->empty()) {
+ setCurrentPathEffect(this->path_effect_list->back());
}
- return lpeitem->current_path_effect;
+ return this->current_path_effect;
}
-Inkscape::LivePathEffect::Effect* sp_lpe_item_get_current_lpe(SPLPEItem *lpeitem)
+Inkscape::LivePathEffect::Effect* SPLPEItem::getCurrentLPE()
{
- Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem);
+ Inkscape::LivePathEffect::LPEObjectReference* lperef = getCurrentLPEReference();
if (lperef && lperef->lpeobject)
return lperef->lpeobject->get_lpe();
@@ -677,11 +677,11 @@ Inkscape::LivePathEffect::Effect* sp_lpe_item_get_current_lpe(SPLPEItem *lpeitem
return NULL;
}
-bool sp_lpe_item_set_current_path_effect(SPLPEItem *lpeitem, Inkscape::LivePathEffect::LPEObjectReference* lperef)
+bool SPLPEItem::setCurrentPathEffect(Inkscape::LivePathEffect::LPEObjectReference* lperef)
{
- for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it) {
+ for (PathEffectList::iterator it = path_effect_list->begin(); it != path_effect_list->end(); ++it) {
if ((*it)->lpeobject_repr == lperef->lpeobject_repr) {
- lpeitem->current_path_effect = (*it); // current_path_effect should always be a pointer from the path_effect_list !
+ this->current_path_effect = (*it); // current_path_effect should always be a pointer from the path_effect_list !
return true;
}
}
@@ -724,21 +724,21 @@ void SPLPEItem::replacePathEffects( std::vector<LivePathEffectObject const *> co
* use this method instead.
* Returns true if one or more effects were forked; returns false if nothing was done.
*/
-bool sp_lpe_item_fork_path_effects_if_necessary(SPLPEItem *lpeitem, unsigned int nr_of_allowed_users)
+bool SPLPEItem::forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users)
{
bool forked = false;
- if ( lpeitem->hasPathEffect() ) {
+ if ( this->hasPathEffect() ) {
// If one of the path effects is used by 2 or more items, fork it
// so that each object has its own independent copy of the effect.
// Note: replacing path effects messes up the path effect list
// Clones of the LPEItem will increase the refcount of the lpeobjects.
// Therefore, nr_of_allowed_users should be increased with the number of clones (i.e. refs to the lpeitem)
- nr_of_allowed_users += lpeitem->hrefcount;
+ nr_of_allowed_users += this->hrefcount;
std::vector<LivePathEffectObject const *> old_lpeobjs, new_lpeobjs;
- PathEffectList effect_list = lpeitem->getEffectList();
+ PathEffectList effect_list = this->getEffectList();
for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it)
{
LivePathEffectObject *lpeobj = (*it)->lpeobject;
@@ -753,7 +753,7 @@ bool sp_lpe_item_fork_path_effects_if_necessary(SPLPEItem *lpeitem, unsigned int
}
if (forked) {
- lpeitem->replacePathEffects(old_lpeobjs, new_lpeobjs);
+ this->replacePathEffects(old_lpeobjs, new_lpeobjs);
}
}