]> Shamusworld >> Repos - architektonas/blob - src/base/block.h
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[architektonas] / src / base / block.h
1 #ifndef __BLOCK_H__
2 #define __BLOCK_H__
3
4 #include <QtCore>
5 #include "document.h"
6
7 /**
8  * Holds the data that defines a block.
9  */
10 class RS_BlockData
11 {
12         public:
13                 RS_BlockData() {}
14
15                 RS_BlockData(const QString & name1, const Vector & basePoint1, bool frozen1):
16                         name(name1), basePoint(basePoint1), frozen(frozen1) {}
17
18                 bool isValid()
19                 {
20                         return (!name.isEmpty() && basePoint.valid);
21                 }
22
23         public:
24                 /**
25                  * Block name. Acts as an id.
26                  */
27                 QString name;
28                 /**
29                  * Base point of the Block. Usually 0/0 since blocks can be moved around
30                  * using the insertion point of Insert entities.
31                  */
32                 Vector basePoint;
33                 //! Frozen flag
34                 bool frozen;
35 };
36
37 /**
38  * A block is a group of entities. A block unlike an other entity
39  * container has a base point which defines the offset of the
40  * block. Note that although technically possible, a block should
41  * never be part of the entity tree of a graphic. Blocks are
42  * stored in a seperate list inside the graphic document (a block list).
43  * The graphic can contain RS_Insert entities that refer to such
44  * blocks.
45  *
46  * blocks are documents and can therefore be handled by graphic views.
47  *
48  * @author Andrew Mustun
49  */
50 class RS_Block: public RS_Document
51 {
52                 friend class RS_BlockList;
53
54         public:
55                 RS_Block(RS_EntityContainer * parent, const RS_BlockData & d);
56                 virtual ~RS_Block();
57
58                 virtual RS_Entity * clone();
59                 virtual RS2::EntityType rtti() const;
60                 QString getName() const;
61                 Vector getBasePoint() const;
62                 virtual RS_LayerList * getLayerList();
63                 virtual RS_BlockList * getBlockList();
64                 virtual void newDoc();
65                 virtual bool save();
66                 virtual bool saveAs(const QString & filename, RS2::FormatType type);
67                 virtual bool open(const QString &, RS2::FormatType);
68                 friend std::ostream & operator<<(std::ostream & os, const RS_Block & b);
69                 void setName(const QString & n);
70                 bool isFrozen() const;
71                 void toggle();
72                 void freeze(bool freeze);
73                 virtual void setModified(bool m);
74
75         protected:
76                 /**
77                 * Base point of the Block. Usually 0/0 since blocks can be moved around
78                 * using the insertion point of Insert entities.
79                 */
80                 //Vector basePoint;
81                 /**
82                 * Block name. Acts as an id.
83                 */
84                 //QString name;
85                 //! Block data
86                 RS_BlockData data;
87 };
88
89 #endif