diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2018-12-16 18:38:00 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2018-12-16 18:38:00 +0000 |
| commit | 7b687013f2544e1085e9c8c911faeedbbaa712b5 (patch) | |
| tree | 3acd2347f0e2c21f5215fbb0139ca62b28650adf /src | |
| parent | Inkscape::URI::Impl -> shared_ptr (diff) | |
| download | inkscape-7b687013f2544e1085e9c8c911faeedbbaa712b5.tar.gz inkscape-7b687013f2544e1085e9c8c911faeedbbaa712b5.zip | |
remove "Perspective path" LPE
- unmaintained "test effect", nobody knows how it works
- broken with (maybe also without?) yaxisdown=true
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/live_effects/effect-enum.h | 1 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 5 | ||||
| -rw-r--r-- | src/live_effects/lpe-perspective_path.cpp | 310 | ||||
| -rw-r--r-- | src/live_effects/lpe-perspective_path.h | 79 |
5 files changed, 0 insertions, 397 deletions
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 84fdd5fa9..a26a7f413 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -40,7 +40,6 @@ set(live_effects_SRC lpe-patternalongpath.cpp lpe-perp_bisector.cpp lpe-perspective-envelope.cpp - lpe-perspective_path.cpp lpe-powerclip.cpp lpe-powermask.cpp lpe-powerstroke.cpp @@ -134,7 +133,6 @@ set(live_effects_SRC lpe-patternalongpath.h lpe-perp_bisector.h lpe-perspective-envelope.h - lpe-perspective_path.h lpe-powerstroke-interpolators.h lpe-powerclip.h lpe-powermask.h diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 80d38c759..b662d3263 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -69,7 +69,6 @@ enum EffectType { PARALLEL, PATH_LENGTH, PERP_BISECTOR, - PERSPECTIVE_PATH, RECURSIVE_SKELETON, TANGENT_TO_CURVE, TEXT_LABEL, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 1ba94a2a2..d55f777e5 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -48,7 +48,6 @@ #include "live_effects/lpe-path_length.h" #include "live_effects/lpe-perp_bisector.h" #include "live_effects/lpe-perspective-envelope.h" -#include "live_effects/lpe-perspective_path.h" #include "live_effects/lpe-powerclip.h" #include "live_effects/lpe-powermask.h" #include "live_effects/lpe-powerstroke.h" @@ -156,7 +155,6 @@ const Util::EnumData<EffectType> LPETypeData[] = { {PARALLEL, N_("Parallel"), "parallel"}, {PATH_LENGTH, N_("Path length"), "path_length"}, {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"}, - {PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"}, {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"}, {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}, {TEXT_LABEL, N_("Text label"), "text_label"}, @@ -222,9 +220,6 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case CIRCLE_WITH_RADIUS: neweffect = static_cast<Effect*> ( new LPECircleWithRadius(lpeobj) ); break; - case PERSPECTIVE_PATH: - neweffect = static_cast<Effect*> ( new LPEPerspectivePath(lpeobj) ); - break; case SPIRO: neweffect = static_cast<Effect*> ( new LPESpiro(lpeobj) ); break; diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp deleted file mode 100644 index 533efa741..000000000 --- a/src/live_effects/lpe-perspective_path.cpp +++ /dev/null @@ -1,310 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** - * @file - * LPE perspective path effect implementation. - */ -/* Authors: - * Maximilian Albert <maximilian.albert@gmail.com> - * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl> - * - * Copyright (C) 2007-2012 Authors - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ -#include <gtkmm.h> - -//#include "transf_mat_3x4.h" -#include "live_effects/lpe-perspective_path.h" -#include "live_effects/lpeobject.h" -#include "knot-holder-entity.h" -#include "knotholder.h" -#include <util/units.h> - -#include "include/gtkmm_version.h" - -#include "object/persp3d.h" -#include "object/sp-defs.h" - -// TODO due to internal breakage in glibmm headers, this must be last: -#include <glibmm/i18n.h> - -namespace Inkscape { -namespace LivePathEffect { - -namespace PP { - -class KnotHolderEntityOffset : public LPEKnotHolderEntity -{ -public: - KnotHolderEntityOffset(LPEPerspectivePath *effect) : LPEKnotHolderEntity(effect) {}; - void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) override; - Geom::Point knot_get() const override; -}; - -} // namespace PP - -static Glib::ustring perspectiveID = _("First perspective"); - - -LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : - Effect(lpeobject), - // initialise your parameters here: - scalex(_("Scale x"), _("Scale factor in x direction"), "scalex", &wr, this, 1.0), - scaley(_("Scale y"), _("Scale factor in y direction"), "scaley", &wr, this, 1.0), - offsetx(_("Offset x"), _("Offset in x direction"), "offsetx", &wr, this, 0.0), - offsety(_("Offset y"), _("Offset in y direction"), "offsety", &wr, this, 0.0), - uses_plane_xy(_("Uses XY plane?"), _("If true, put the path on the left side of an imaginary box, otherwise on the right side"), "uses_plane_xy", &wr, this, true) -{ - // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter( &scalex); - registerParameter( &scaley); - registerParameter( &offsetx); - registerParameter( &offsety); - registerParameter( &uses_plane_xy); - - concatenate_before_pwd2 = true; // don't split the path into its subpaths - _provides_knotholder_entities = true; - apply_to_clippath_and_mask = true; -} - -LPEPerspectivePath::~LPEPerspectivePath() -= default; -void -LPEPerspectivePath::doOnApply(SPLPEItem const* lpeitem) -{ - Persp3D *persp = persp3d_document_first_persp(lpeitem->document); - if(persp == nullptr ){ - char *msg = _("You need a BOX 3D object"); - Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, - Gtk::BUTTONS_OK, true); - dialog.run(); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->removeCurrentPathEffect(false); - } -} -void -LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem) -{ - original_bbox(lpeitem, true); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - Persp3D *persp = persp3d_document_first_persp(lpeitem->document); - if(persp == nullptr ){ - char *msg = _("You need a BOX 3D object"); - Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, - Gtk::BUTTONS_OK, true); - dialog.run(); - return; - } - Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; - Geom::Affine doc2d = Geom::Scale(1, -1) * Geom::Translate(0, item->document->getHeight().value("px")); - pmat = pmat * doc2d; - pmat.copy_tmat(tmat); -} - -void LPEPerspectivePath::refresh(Gtk::Entry* perspective) { - perspectiveID = perspective->get_text(); - Persp3D *first = nullptr; - Persp3D *persp = nullptr; - for (auto& child: lpeobj->document->getDefs()->children) { - if (SP_IS_PERSP3D(&child) && first == nullptr) { - first = SP_PERSP3D(&child); - } - if (SP_IS_PERSP3D(&child) && strcmp(child.getId(), const_cast<const gchar *>(perspectiveID.c_str())) == 0) { - persp = SP_PERSP3D(&child); - break; - } - } - if(first == nullptr ){ - char *msg = _("You need a BOX 3D object"); - Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, - Gtk::BUTTONS_OK, true); - dialog.run(); - return; - } - if(persp == nullptr){ - persp = first; - char *msg = _("First perspective selected"); - Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, - Gtk::BUTTONS_OK, true); - dialog.run(); - perspectiveID = _("First perspective"); - }else{ - char *msg = _("Perspective changed"); - Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, - Gtk::BUTTONS_OK, true); - dialog.run(); - } - Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; - pmat = pmat * SP_ACTIVE_DESKTOP->doc2dt(); - pmat.copy_tmat(tmat); -}; - -Geom::Piecewise<Geom::D2<Geom::SBasis> > -LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) -{ - using namespace Geom; - - Piecewise<D2<SBasis> > path_a_pw = pwd2_in; - - // FIXME: the minus sign is there because the SVG coordinate system goes down; - // remove this once we have unified coordinate systems - path_a_pw = path_a_pw + Geom::Point(offsetx, -offsety); - - D2<Piecewise<SBasis> > B = make_cuts_independent(path_a_pw); - Piecewise<SBasis> preimage[4]; - - //Geom::Point orig = Geom::Point(bounds_X.min(), bounds_Y.middle()); - //orig = Geom::Point(orig[X], sp_document_height(this->lpeobj->document) - orig[Y]); - - //double offset = uses_plane_xy ? boundingbox_X.extent() : 0.0; - - orig = Point(uses_plane_xy ? boundingbox_X.max() : boundingbox_X.min(), boundingbox_Y.middle()); - - /** - g_print ("Orig: (%8.2f, %8.2f)\n", orig[X], orig[Y]); - - g_print ("B[1] - orig[1]: %8.2f\n", (B[1] - orig[1])[0].valueAt(0)); - g_print ("B[0] - orig[0]: %8.2f\n", (B[0] - orig[0])[0].valueAt(0)); - **/ - - if (uses_plane_xy) { - preimage[0] = (-B[0] + orig[0]) * scalex / 200.0; - preimage[1] = ( B[1] - orig[1]) * scaley / 400.0; - preimage[2] = B[0] - B[0]; // hack! - } else { - preimage[0] = B[0] - B[0]; // hack! - preimage[1] = (B[1] - orig[1]) * scaley / 400.0; - preimage[2] = (B[0] - orig[0]) * scalex / 200.0; - } - - /* set perspective origin to first point of path */ - tmat[0][3] = orig[0]; - tmat[1][3] = orig[1]; - - /** - g_print ("preimage[1]: %8.2f\n", preimage[1][0].valueAt(0)); - g_print ("preimage[2]: %8.2f\n", preimage[2][0].valueAt(0)); - **/ - - Piecewise<SBasis> res[3]; - for (int j = 0; j < 3; ++j) { - res[j] = - preimage[0] * tmat[j][0] - + preimage[1] * tmat[j][1] - + preimage[2] * tmat[j][2] - + tmat[j][3]; - } - D2<Piecewise<SBasis> > result(divide(res[0],res[2], 3), - divide(res[1],res[2], 3)); - - Piecewise<D2<SBasis> > output = sectionize(result); - - return output; -} - -Gtk::Widget * -LPEPerspectivePath::newWidget() -{ - // use manage here, because after deletion of Effect object, others might still be pointing to this widget. - Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); - - vbox->set_border_width(5); - std::vector<Parameter *>::iterator it = param_vector.begin(); - while (it != param_vector.end()) { - if ((*it)->widget_is_visible) { - Parameter * param = *it; - Gtk::Widget * widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget()); - Glib::ustring * tip = param->param_getTooltip(); - if (widg) { - vbox->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } - } - } - - ++it; - } - Gtk::HBox * perspectiveId = Gtk::manage(new Gtk::HBox(true,0)); - -#if GTKMM_CHECK_VERSION(3,10,0) - Gtk::Label* labelPerspective = Gtk::manage(new Gtk::Label("Perspective ID:", Gtk::ALIGN_START, Gtk::ALIGN_START)); -#else - Gtk::Label* labelPerspective = Gtk::manage(new Gtk::Label("Perspective ID:", 0., 0.)); -#endif - - Gtk::Entry* perspective = Gtk::manage(new Gtk::Entry()); - perspective->set_text(perspectiveID); - perspective->set_tooltip_text("Set the perspective ID to apply"); - perspectiveId->pack_start(*labelPerspective, true, true, 2); - perspectiveId->pack_start(*perspective, true, true, 2); - vbox->pack_start(*perspectiveId, true, true, 2); - Gtk::Button* apply3D = Gtk::manage(new Gtk::Button()); - -#if GTKMM_CHECK_VERSION(3,10,0) - Gtk::Label *apply3DLabel = Gtk::manage(new Gtk::Label(_("Refresh perspective"), Gtk::ALIGN_START, Gtk::ALIGN_CENTER)); -#else - Gtk::Label *apply3DLabel = Gtk::manage(new Gtk::Label(_("Refresh perspective"), 0.0, 0.5)); -#endif - - apply3D->add(*apply3DLabel); - apply3D->signal_clicked().connect(sigc::bind<Gtk::Entry*>(sigc::mem_fun(*this,&LPEPerspectivePath::refresh),perspective)); - Gtk::Widget* apply3DWidget = dynamic_cast<Gtk::Widget *>(apply3D); - apply3DWidget->set_tooltip_text("Refresh perspective"); - vbox->pack_start(*apply3DWidget, true, true,2); - if(Gtk::Widget* widg = defaultParamSet()) { - vbox->pack_start(*widg, true, true, 2); - } - return dynamic_cast<Gtk::Widget *>(vbox); -} - -void LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item) { - KnotHolderEntity *e = new PP::KnotHolderEntityOffset(this); - e->create( nullptr, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the origin") ); - knotholder->add(e); -}; - -namespace PP { - -void -KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) -{ - using namespace Geom; - - LPEPerspectivePath* lpe = dynamic_cast<LPEPerspectivePath *>(_effect); - - Geom::Point const s = snap_knot_position(p, state); - - lpe->offsetx.param_set_value((s - origin)[Geom::X]); - lpe->offsety.param_set_value(-(s - origin)[Geom::Y]); // additional minus sign is due to coordinate system flipping - - // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. - sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); -} - -Geom::Point -KnotHolderEntityOffset::knot_get() const -{ - LPEPerspectivePath const *lpe = dynamic_cast<LPEPerspectivePath const*>(_effect); - return lpe->orig + Geom::Point(lpe->offsetx, -lpe->offsety); -} - -} // namespace PP - -} //namespace LivePathEffect -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/live_effects/lpe-perspective_path.h b/src/live_effects/lpe-perspective_path.h deleted file mode 100644 index d050ce93b..000000000 --- a/src/live_effects/lpe-perspective_path.h +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** @file - * @brief LPE perspective path effect implementation - */ -/* Authors: - * Maximilian Albert <maximilian.albert@gmail.com> - * Johan Engelen <j.b.c.engelen@utwente.nl> - * - * Copyright (C) 2007 Authors - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#ifndef INKSCAPE_LPE_PERSPECTIVE_PATH_H -#define INKSCAPE_LPE_PERSPECTIVE_PATH_H - -#include "live_effects/effect.h" -#include "live_effects/parameter/parameter.h" -#include "live_effects/parameter/bool.h" -#include "live_effects/lpegroupbbox.h" - -#include <vector> -#include "2geom/point.h" - -namespace Inkscape { -namespace LivePathEffect { - -namespace PP { - // we need a separate namespace to avoid clashes with other LPEs - class KnotHolderEntityOffset; -} - -class LPEPerspectivePath : public Effect, GroupBBoxEffect { -public: - LPEPerspectivePath(LivePathEffectObject *lpeobject); - ~LPEPerspectivePath() override; - void doBeforeEffect (SPLPEItem const* lpeitem) override; - void doOnApply(SPLPEItem const* lpeitem) override; - Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) override; - - virtual void refresh(Gtk::Entry* perspective); - Gtk::Widget * newWidget() override; - /* the knotholder entity classes must be declared friends */ - friend class PP::KnotHolderEntityOffset; - void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item) override; - -private: - // add the parameters for your effect here: - ScalarParam scalex; - ScalarParam scaley; - // TODO: rewrite this using a PointParam instead of two ScalarParams - ScalarParam offsetx; - ScalarParam offsety; - BoolParam uses_plane_xy; - // there are all kinds of parameters. Check the /live_effects/parameter directory which types exist! - Geom::Point orig; - - LPEPerspectivePath(const LPEPerspectivePath&) = delete; - LPEPerspectivePath& operator=(const LPEPerspectivePath&) = delete; - - std::vector<Geom::Point> handles; - double tmat[3][4]; -}; - -} //namespace LivePathEffect -} //namespace Inkscape - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |
