openEmbroider  0.1
an open source embroidery software
OE_instruction.h
1 /*
2  * Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  *
20  */
21 
22 #ifndef OE_BASE_H
23 #define OE_BASE_H
24 
25 #include "OE_utils.h"
26 #include "OE_thread.h"
27 #include <stdint.h>
28 #include <list>
29 
30 class OE_base
31 {
32  public:
34  OE_base();
36  virtual ~OE_base();
37 
38  bool getNeedRefresh();
39  void setNeedRefresh();
40 
44  void addDependency(OE_base * object);
45  void removeDependency(OE_base * object);
46 
50  virtual void delDependency(OE_base * object){};
51 
55  virtual void getBound(float* xMin, float* yMin, float* xMax, float* yMax) = 0;
56 
58  virtual bool check() = 0;
59 
60  virtual void refresh() = 0;
61 
62  protected:
63 
64  std::list<OE_base*> objects;
65 
67  float bounds[4];
68 
70  bool needRefresh = true;
71 
77  static bool ptInBounds( vector_2d pt, float* bounds);
78  private:
79 
80 };
81 
82 #endif // OE_BASE_H
static bool ptInBounds(vector_2d pt, float *bounds)
check if a point is in a given bounding box
Definition: OE_base.cpp:51
float bounds[4]
Tight bounding box of the object [minx,miny,maxx,maxy].
Definition: OE_base.h:67
virtual void getBound(float *xMin, float *yMin, float *xMax, float *yMax)=0
calculate the object bounding box
OE_base()
Definition: OE_base.cpp:24
virtual bool check()=0
check if the object is valid.
virtual ~OE_base()
Definition: OE_base.cpp:28
Definition: OE_base.h:30
bool needRefresh
flag to know who must be refreeshed
Definition: OE_base.h:70
Definition: OE_utils.h:28
virtual void delDependency(OE_base *object)
the function called by a reference object when he's deleted
Definition: OE_instruction.h:50
void addDependency(OE_base *object)
add and remove dependency from the list
Definition: OE_base.cpp:56