]> Shamusworld >> Repos - architektonas/blob - src/base/clipboard.h
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[architektonas] / src / base / clipboard.h
1 #ifndef __CLIPBOARD_H__
2 #define __CLIPBOARD_H__
3
4 #include <iostream>
5 #include "drawing.h"
6
7 #define RS_CLIPBOARD RS_Clipboard::instance()
8
9 class RS_Block;
10 class RS_Layer;
11 class RS_Entity;
12
13 /**
14  * QCad internal clipboard. We don't use the system clipboard for
15  * better portaility.
16  * Implemented as singleton.
17  *
18  * @author Andrew Mustun
19  */
20 class RS_Clipboard {
21 protected:
22     RS_Clipboard() {
23     }
24
25 public:
26     /**
27      * @return Instance to the unique clipboard object.
28      */
29     static RS_Clipboard* instance() {
30         if (uniqueInstance==NULL) {
31             uniqueInstance = new RS_Clipboard();
32         }
33         return uniqueInstance;
34     }
35
36         void clear();
37
38         void addBlock(RS_Block* b);
39         bool hasBlock(const QString& name);
40         int  countBlocks() {
41                 return graphic.countBlocks();
42         }
43         RS_Block* blockAt(int i) {
44                 return graphic.blockAt(i);
45         }
46
47         void addLayer(RS_Layer* l);
48         bool hasLayer(const QString& name);
49         int  countLayers() {
50                 return graphic.countLayers();
51         }
52         RS_Layer* layerAt(int i) {
53                 return graphic.layerAt(i);
54         }
55
56         void addEntity(RS_Entity* e);
57
58         uint count() {
59                 return graphic.count();
60         }
61         RS_Entity* entityAt(uint i) {
62                 return graphic.entityAt(i);
63         }
64         RS_Entity* firstEntity() {
65                 return graphic.firstEntity();
66         }
67
68         RS_Entity* nextEntity() {
69                 return graphic.nextEntity();
70         }
71
72         Drawing* getGraphic() {
73                 return &graphic;
74         }
75
76     friend std::ostream& operator << (std::ostream& os, RS_Clipboard& cb);
77
78 protected:
79     static RS_Clipboard* uniqueInstance;
80
81         Drawing graphic;
82 };
83
84 #endif
85