1
/****************************************************************************
3
** This file is part of the LibreCAD project, a 2D CAD program
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
9
** This file may be distributed and/or modified under the terms of the
10
** GNU General Public License version 2 as published by the Free Software
11
** Foundation and appearing in the file gpl-2.0.txt included in the
12
** packaging of this file.
14
** This program is distributed in the hope that it will be useful,
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
** GNU General Public License for more details.
19
** You should have received a copy of the GNU General Public License
20
** along with this program; if not, write to the Free Software
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
** This copyright notice MUST APPEAR in all copies of the script!
25
**********************************************************************/
31
#include "rs_layerlist.h"
32
#include "rs_entitycontainer.h"
38
* Base class for documents. Documents can be either graphics or
39
* blocks and are typically shown in graphic views. Documents hold
40
* an active pen for drawing in the Document, a file name and they
41
* know whether they have been modified or not.
43
* @author Andrew Mustun
45
class RS_Document : public RS_EntityContainer,
48
RS_Document(RS_EntityContainer* parent=NULL);
49
virtual ~RS_Document(){}
51
virtual RS_LayerList* getLayerList() = 0;
52
virtual RS_BlockList* getBlockList() = 0;
54
virtual void newDoc() = 0;
55
virtual bool save(bool isAutoSave = false) = 0;
56
virtual bool saveAs(const QString &filename, RS2::FormatType type, bool force) = 0;
57
virtual bool open(const QString &filename, RS2::FormatType type) = 0;
58
virtual bool loadTemplate(const QString &filename, RS2::FormatType type) = 0;
62
* @return true for all document entities (e.g. Graphics or Blocks).
64
virtual bool isDocument() const {
69
* Removes an entity from the entiy container. Implementation
72
virtual void removeUndoable(RS_Undoable* u) {
73
if (u!=NULL && u->undoRtti()==RS2::UndoableEntity) {
74
removeEntity((RS_Entity*)u);
79
* @return Currently active drawing pen.
81
RS_Pen getActivePen() const {
86
* Sets the currently active drawing pen to p.
88
void setActivePen(RS_Pen p) {
93
* @return File name of the document currently loaded.
94
* Note, that the default file name is empty.
96
QString getFilename() const {
101
* @return Auto-save file name of the document currently loaded.
103
QString getAutoSaveFilename() const {
104
return autosaveFilename;
108
* Sets file name for the document currently loaded.
110
void setFilename(const QString& fn) {
115
* Sets the documents modified status to 'm'.
117
virtual void setModified(bool m) {
118
//std::cout << "RS_Document::setModified: %d" << (int)m << std::endl;
123
* @retval true The document has been modified since it was last saved.
124
* @retval false The document has not been modified since it was last saved.
126
virtual bool isModified() const {
131
* Overwritten to set modified flag before starting an undo cycle.
133
virtual void startUndoCycle() {
135
RS_Undo::startUndoCycle();
138
void setGraphicView(RS_GraphicView * g) {gv = g;}
139
RS_GraphicView* getGraphicView() {return gv;}
142
/** Flag set if the document was modified and not yet saved. */
146
/** File name of the document or empty for a new document. */
148
/** Auto-save file name of document. */
149
QString autosaveFilename;
151
RS2::FormatType formatType;
152
RS_GraphicView * gv;//used to read/save current view