Skip to content
OE_document.h 3.29 KiB
Newer Older
3dsman's avatar
3dsman committed
/*
 * 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.
 *
 */

#ifndef OE_DOCUMENT_H
#define OE_DOCUMENT_H

#include <string>
#include <pthread.h>
//#include "xml/tinyxml.h"
#include "stitchs/OE_stitchs.h"
#include "curves/OE_pointcurve.h"
#include "instructions/OE_instruction.h"
//#include "actions/OE_actions.h"
3dsman's avatar
3dsman committed

class OE_actions;

class OE_document
3dsman's avatar
3dsman committed
{
    public:
        /** Default constructor */
        OE_document();
       // OE_document(std::string filename);
3dsman's avatar
3dsman committed
        /** Default destructor */
        virtual ~OE_document();
3dsman's avatar
3dsman committed
	
		/** \brief the list of stitchs	 */
        std::list<OE_stitchs*> stitchs;
3dsman's avatar
3dsman committed
		
		/** \brief the list of curves	 */
		/** \brief the list of threads	 */
		std::list<OE_thread*> threads;
		/** \brief the list of selected stitchs	 */
        std::list<OE_stitchs*> selectedStitchs;
		/** \brief the list of selected curves	 */
		std::list<OE_curve*> selectedCurves;
		/** \brief the array of points to send to the embroideress	 */
		std::vector<vector_2d> instPoints;
		
		/** \brief the array of commands to send to the embroideress	 */
		std::vector<OE_instruction*> instCommand;


        /** \brief the stack of active actions	 */
        std::list<OE_actions*> activeActionsStack;

        /** \brief the stack of undoed actions	 */
        std::list<OE_actions*> undoActionsStack;

		
		/** \brief the current points stitched by the embroideress	 */
		unsigned int curPoint = 0;
		
		void getBound(float* xMin, float* yMin, float* xMax, float* yMax);
		
		vector_2d getHoopSize();
		unsigned int getPulseByMm();
		vector_2d getZeroPoint();
		void setHoopSize(vector_2d hoopSize);
		void setPulseByMm(unsigned int pbm);
		void setZeroPoint(vector_2d zeroPoint);
		
		bool addCurve(OE_curve * curve);
		bool addStitch(OE_stitchs * stitch);
		bool addThread(OE_thread * thread);

        bool removeCurve(OE_curve * curve);
        bool removeStitch(OE_stitchs * stitch);
        bool removeThread(OE_thread * thread);
		void lock(); // lock write
		int trylock(); // try to lock write, return 0 if success
		void unlock(); // unlock write

3dsman's avatar
3dsman committed
    private:
		/** \brief Width of the document.	 */
    float width; 
	
		/** \brief Height of the document.	 */
	float height;
	
	unsigned int pulseByMm = 5;
	
	float scale = 0.50f;
	
	vector_2d hoopSize = vector_2d(150,160) ;
	
	vector_2d zeroPoint = vector_2d(0,0) ;

	pthread_mutex_t writeLock;
3dsman's avatar
3dsman committed
};

#endif // OE_DOCUMENT_H