Newer
Older
/*
* Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
*/
#include "OE_controller.h"
#include <iostream>
#include <typeinfo>
#include "actions/OE_actionsCurves.h"
#include "actions/OE_actionsStitchs.h"
#include "actions/OE_actionsLineStitchs.h"
#include "actions/OE_actionsBirailStitchs.h"
#include "actions/OE_actionsSelection.h"
#include "actions/OE_actionsThreads.h"
//OE_controller::OE_controller(OE_display * display, OE_document* document ) : comm("/dev/ttyUSB0", 80, 10)
//OE_controller::OE_controller(OE_display * display, OE_document* document ) : comm("/dev/tty", 80, 10)
//OE_controller::OE_controller(OE_display * display, OE_document* document ) : comm("20:15:05:11:28:40", 80, 30)
OE_controller::OE_controller(OE_display * display, OE_document* document ) : comm("/dev/rfcomm1", 80, 30)
{
this->display = display;
this->document = document;
OE_linestitch::initMotifs();
// TODO remove
if (document && document->threads.empty())
document->addThread(new OE_thread(100,100,100,2));
}
OE_controller::~OE_controller()
{
}
void OE_controller::setDocument(OE_document* document)
{
this->document = document;
}
3dsman
committed
/*
void OE_controller::newSubCurve(OE_curve* curve, float curveStart, float curveEnd, bool reverse)
addAction(new OE_actionNewSubCurve(curve, curveStart, curveEnd, reverse));
}
void OE_controller::newSubCurve(int ncurve, float curveStart, float curveEnd, bool reverse)
{
newSubCurve(getCurve(ncurve), curveStart, curveEnd, reverse);
}
3dsman
committed
*/
void OE_controller::newBirailStitch(bool reverse1, bool reverse2, float offset1, float offset2, float len)
clearUndoActionStack();
addAction(new OE_actionNewBirailStitch(reverse1, reverse2, offset1, offset2, len));
void OE_controller::newBirailStitch(int ncurve1, int ncurve2, bool reverse1, bool reverse2, float offset1, float offset2, float len)
{
newBirailStitch(getCurve(ncurve1), getCurve(ncurve2), reverse1, reverse2, offset1, offset2, len);
}
/*
void OE_controller::newJoinCurve(OE_subcurve* curve1, OE_subcurve* curve2)
{
addAction(new OE_actionNewJoinCurve(curve1, curve2));
}
void OE_controller::newJoinCurve(int ncurve1, int ncurve2)
{
newJoinCurve(getCurve(ncurve1), getCurve(ncurve2));
}
*/
void OE_controller::newLineStitch( float len, float width, unsigned motif, float offset)
clearUndoActionStack();
addAction(new OE_actionNewLineStitch( len, width, motif, offset));
void OE_controller::newLineStitch(int ncurve, float len, float width, unsigned motif, float offset)
{
void OE_controller::setStitchThread(OE_stitchs* stitch, OE_thread * thread)
{
addAction(new OE_actionSetStitchThread(stitch, thread));
}
void OE_controller::setStitchThread(int nstitch, int nthread)
{
setStitchThread(getStitch(nstitch), getThread(nthread));
}
void OE_controller::setCloseCurve(OE_curve* curve, bool closed)
{
addAction(new OE_actionSetCloseCurve(curve, closed));
}
void OE_controller::setCloseCurve(int ncurve, bool closed)
{
setCloseCurve(getCurve(ncurve), closed);
}
void OE_controller::toggleCloseSelectedCurve()
{
OE_curve* curve = document->selectedCurves.back();
if (curve) setCloseCurve(curve, !curve->getClosed());
}
bool OE_controller::initNewDocument()
{
if (document)
{
OE_actions::curDocument = document; // TODO: REMOVE, UGLY AS FUCK !!!!
addAction(new OE_actionNewThread(new OE_thread(220,120,20,2)));
document->setZeroPoint(vector_2d(0,0));
return true;
}
return false;
}
bool OE_controller::testLogo2()
// test motifs
if (document)
{
OE_actions::curDocument = document; // TODO: REMOVE, UGLY AS FUCK !!!!
addAction(new OE_actionNewThread(new OE_thread(220,120,20,2)));
document->setZeroPoint(vector_2d(0,1050));
addAction(new OE_actionNewMetaLineStitch(1.2,0.5,1,0));
addAction(new OE_actionJoincurveAddSubCurve(getMetaLineStitch(-1)->getJoinCurve(),-1,getCurve(1),0,1,false));
addAction(new OE_actionJoincurveAddSubCurve(getMetaLineStitch(-1)->getJoinCurve(),-1,getCurve(1),2,3.5,false));
//addAction(new OE_actionAddMetaLineStitchSubCurve(getMetaLineStitch(document->stitchs.size()-1),getCurve(1),0,1));
//addAction(new OE_actionAddMetaLineStitchSubCurve(getMetaLineStitch(document->stitchs.size()-1),getCurve(1),2,3.5));
// interrieur 1er rectangle
newSubCurve(2, 2, 3, false);
newSubCurve(2, 0, 1, true);
newBirailStitch(-1, -2, false, false, -0.2, -0.2, 0.5);
setStitchThread(-1 , 1);
// interrieur 2eme rectangle
newSubCurve(4, 2, 4, true);
newSubCurve(4, 6, 1, false);
newBirailStitch(-1, -2, false, false, 0.2, 0.2, 0.5);
setStitchThread(-1, 1);
// interrieur 3eme rectangle
newSubCurve(3, 0, 1, false);
newSubCurve(3, 2, 3, true);
newBirailStitch(-1, -2, false, false, -0.2, -0.2, 0.5);
setStitchThread(-1, 1);
addAction(new OE_actionNewThread(new OE_thread(120,220,20,2)));
//addThread(120,220,20,2);
3dsman
committed
// circle logo
newSubCurve(1, 0, 2, true);
newSubCurve(1, 2, 4, true);
newJoinCurve(-2, -1);
newBirailStitch(0, -1, false, false, 0.2, 0.2, 0.5);
addAction(new OE_actionSetStitchMaxLen(getStitch(-1),5));
//selectCurve(getCurve(-1), true);
newSubCurve(5, 9, 10, false);
newSubCurve(5, 11, 12, true);
newBirailStitch(-1, -2, false, false, 0.2, 0.2, 0.5);
Loading full blame...