1
/***************************************************************************
2
* Copyright (c) J�rgen Riegel (juergen.riegel@web.de) *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
26
#ifndef APP_DOCUMENTOBJECT_H
27
#define APP_DOCUMENTOBJECT_H
29
#include <App/PropertyContainer.h>
30
#include <App/PropertyStandard.h>
32
#include <Base/TimeInfo.h>
33
#include <CXX/Objects.hxx>
41
class DocumentObjectPy;
43
/** Return object for feature execution
45
class AppExport DocumentObjectExecReturn
48
DocumentObjectExecReturn(const std::string& sWhy, DocumentObject* WhichObject=0)
49
: Why(sWhy), Which(WhichObject)
52
DocumentObjectExecReturn(const char* sWhy, DocumentObject* WhichObject=0)
60
DocumentObject* Which;
65
/** Base class of all Classes handled in the Document
67
class AppExport DocumentObject: public App::PropertyContainer
69
PROPERTY_HEADER(App::DocumentObject);
75
/// returns the type name of the ViewProvider
76
virtual const char* getViewProviderName(void) const {
81
virtual ~DocumentObject();
84
/// returns the name which is set in the document for this object (not the Name propertie!)
85
const char *getNameInDocument(void) const;
86
/// gets the document in which this Object is handled
87
App::Document *getDocument(void) const;
89
/** Set the property touched -> changed, cause recomputation in Update()
92
/// set this feature touched (cause recomputation on depndend features)
94
/// test if this feature is touched
95
bool isTouched(void) const {return StatusBits.test(0);}
96
/// reset this feature touched
97
void purgeTouched(void){StatusBits.reset(0);setPropertyStatus(0,false);}
98
/// set this feature to error
99
bool isError(void) const {return StatusBits.test(1);}
100
bool isValid(void) const {return !StatusBits.test(1);}
101
/// remove the error from the object
102
void purgeError(void){StatusBits.reset(1);}
105
/** get called by the document to recompute this feature
106
* Normaly this methode get called in the processing of
107
* Document::recompute().
108
* In execute() the outpupt properties get recomputed
109
* with the data from linked objects and objects own
112
virtual App::DocumentObjectExecReturn *execute(void);
115
* We call this method to check if the object was modified to
116
* be invoked. If the object label or an argument is modified.
117
* If we must recompute the object - to call the method execute().
118
* 0: no recompution is needed
119
* 1: recompution needed
120
* -1: the document examine all links of this object and if one is touched -> recompute
122
virtual short mustExecute(void) const;
125
/// get the status Message
126
const char *getStatusString(void) const;//{return _cStatusMessage.c_str();}
130
/** Called in case of losing a link
131
* Get called by the document when a object got deleted a link property of this
132
* object ist pointing to. The standard behaivour of the DocumentObject implementation
133
* is to reset the links to nothing. You may overide this methode to implement
134
*additional or different behavior.
136
virtual void onLoseLinkToObject(DocumentObject*);
137
virtual PyObject *getPyObject(void);
139
friend class Document;
140
friend class Transaction;
142
static DocumentObjectExecReturn *StdReturn;
144
virtual void Save (Base::Writer &writer) const;
149
/** status bits of the document object
150
* the first 8 bits are used for the base system
151
* the rest can be used in descendend classes to
152
* to mark special stati on the objects
154
std::bitset<32> StatusBits;
156
void setError(void){StatusBits.set(1);}
157
void resetError(void){StatusBits.reset(1);}
158
void setDocument(App::Document* doc);
160
/// get called befor the value is changed
161
virtual void onBeforeChange(const Property* prop);
162
/// get called by the container when a property was changed
163
virtual void onChanged(const Property* prop);
165
/// python object of this class and all descendend
166
protected: // attributes
167
Py::Object PythonObject;
168
/// pointer to the document this object belongs to
169
App::Document* _pDoc;
171
// pointer to the document name string (for performance)
172
const std::string *pcNameInDocument;
178
#endif // APP_DOCUMENTOBJECT_H