/*
* Copyright (C) JF Barraud 2007 <jf.barraud@gmail.com>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-vonkoch.h"
//using std::vector;
namespace Inkscape {
namespace LivePathEffect {
void
{
//sp_nodepath_make_straight_path(np);
}
//FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug.
void
{
//sp_nodepath_make_straight_path(np);
}
bool
{
return true;
}else{
_pathvector = old;
return false;
}
}
nbgenerations(_("N_r of generations:"), _("Depth of the recursion --- keep low!!"), "nbgenerations", &wr, this, 1),
generator(_("Generating path:"), _("Path whose segments define the iterated transforms"), "generator", &wr, this, "M0,0 L30,0 M0,10 L10,10 M 20,10 L30,10"),
similar_only(_("_Use uniform transforms only"), _("2 consecutive segments are used to reverse/preserve orientation only (otherwise, they define a general transform)."), "similar_only", &wr, this, false),
drawall(_("Dra_w all generations"), _("If unchecked, draw only the last generation"), "drawall", &wr, this, true),
//,draw_boxes(_("Display boxes"), _("Display boxes instead of paths only"), "draw_boxes", &wr, this, true)
ref_path(_("Reference segment:"), _("The reference segment. Defaults to the horizontal midline of the bbox."), "ref_path", &wr, this, "M0,0 L10,0"),
//refA(_("Ref Start"), _("Left side middle of the reference box"), "refA", &wr, this),
//refB(_("Ref End"), _("Right side middle of the reference box"), "refB", &wr, this),
//FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug.
maxComplexity(_("_Max complexity:"), _("Disable effect if the output is too complex"), "maxComplexity", &wr, this, 1000)
{
//FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug.
//registerParameter( dynamic_cast<Parameter *>(&refA) );
//registerParameter( dynamic_cast<Parameter *>(&refB) );
//registerParameter( dynamic_cast<Parameter *>(&draw_boxes) );
apply_to_clippath_and_mask = true;
}
LPEVonKoch::~LPEVonKoch()
{
}
{
using namespace Geom;
if (generating_path.empty()) {
return path_in;
}
//Collect transform matrices.
Point u = B-A;
//FIXME: a path is used as ref instead of 2 points to work around path/point param incompatibility bug.
//Point u = refB-refA;
//m0 = Affine(u[X], u[Y],-u[Y], u[X], refA[X], refA[Y]);
for (unsigned i=0; i<generating_path.size(); i++){
Affine m;
m = Affine(u[X], u[Y],-u[Y], u[X], p[X], p[Y]);
m = m0*m;
transforms.push_back(m);
if (similar_only.get_value()){
v[X] = -u[Y]*sign;
v[Y] = u[X]*sign;
}
m = Affine(u[X], u[Y],v[X], v[Y], p[X], p[Y]);
m = m0*m;
transforms.push_back(m);
}
}
if (transforms.empty()){
return path_in;
}
//Do nothing if the output is too complex...
int path_in_complexity = 0;
}
int k = transforms.size();
if(k>1){
}else{
}
}
if (complexity > double(maxComplexity)){
g_warning("VonKoch lpe's output too complex. Effect bypassed.");
return path_in;
}
//Generate path:
for (unsigned i = 0; i<nbgenerations; i++){
}else{
complexity = 0;
}
for (unsigned j = 0; j<transforms.size(); j++){
}
}
}
return path_out;
}
//Usefull??
//void
//LPEVonKoch::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
/*{
using namespace Geom;
if (draw_boxes.get_value()){
double ratio = .5;
if (similar_only.get_value()) ratio = boundingbox_Y.extent()/boundingbox_X.extent()/2;
Point BB1,BB2,BB3,BB4,v;
//Draw the reference box (ref_path is supposed to consist in one line segment)
//FIXME: a path is used as ref instead of 2 points to work around path/point param incompatibility bug.
Geom::Path refpath = ref_path.get_pathvector().front();
if (refpath.size()==1){
BB1 = BB4 = refpath.front().pointAt(0);
BB2 = BB3 = refpath.front().pointAt(1);
v = rot90(BB2 - BB1)*ratio;
BB1 -= v;
BB2 -= v;
BB3 += v;
BB4 += v;
Geom::Path refbox(BB1);
refbox.appendNew<LineSegment>(BB2);
refbox.appendNew<LineSegment>(BB3);
refbox.appendNew<LineSegment>(BB4);
refbox.close();
PathVector refbox_as_vect;
refbox_as_vect.push_back(refbox);
hp_vec.push_back(refbox_as_vect);
}
//Draw the transformed boxes
Geom::PathVector generating_path = generator.get_pathvector();
for (unsigned i=0;i<generating_path.size(); i++){
if (generating_path[i].size()==0){
//Ooops! this should not happen.
}else if (generating_path[i].size()==1){
BB1 = BB4 = generating_path[i].pointAt(0);
BB2 = BB3 = generating_path[i].pointAt(1);
v = rot90(BB2 - BB1)*ratio;
}else{//Only tak the first 2 segments into account.
BB1 = BB4 = generating_path[i].pointAt(1);
BB2 = BB3 = generating_path[i].pointAt(2);
if(similar_only.get_value()){
v = rot90(BB2 - BB1)*ratio;
}else{
v = (generating_path[i].pointAt(0) - BB1)*ratio;
}
}
BB1 -= v;
BB2 -= v;
BB3 += v;
BB4 += v;
Geom::Path path(BB1);
path.appendNew<LineSegment>(BB2);
path.appendNew<LineSegment>(BB3);
path.appendNew<LineSegment>(BB4);
path.close();
PathVector pathv;
pathv.push_back(path);
hp_vec.push_back(pathv);
}
}
}
*/
void
{
using namespace Geom;
//FIXME: a path is used as ref instead of 2 points to work around path/point param incompatibility bug.
//refA.param_setValue( Geom::Point(boundingbox_X.min(), boundingbox_Y.middle()) );
//refB.param_setValue( Geom::Point(boundingbox_X.max(), boundingbox_Y.middle()) );
}else{
}
}
}
void
{
using namespace Geom;
Point A,B;
//FIXME: a path is used as ref instead of 2 points to work around path/point param incompatibility bug.
//refA[Geom::X] = boundingbox_X.min();
//refA[Geom::Y] = boundingbox_Y.middle();
//refB[Geom::X] = boundingbox_X.max();
//refB[Geom::Y] = boundingbox_Y.middle();
//Geom::PathVector paths;
//Geom::Path path = Geom::Path( (Point) refA);
//path.appendNew<Geom::LineSegment>( (Point) refB );
//paths.push_back(path * Affine(1./3,0,0,1./3, refA[X]*2./3, refA[Y]*2./3 + boundingbox_Y.extent()/2));
//paths.push_back(path * Affine(1./3,0,0,1./3, refB[X]*2./3, refB[Y]*2./3 + boundingbox_Y.extent()/2));
//paths.push_back(path);
//generator.set_new_value(paths, true);
}
} // 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 :