Gui/Document.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef GUI_DOCUMENT_H
00025 #define GUI_DOCUMENT_H
00026
00027 #include "MDIView.h"
00028
00029 #include <list>
00030 #include <map>
00031 #include <string>
00032
00033 #include <Base/Persistence.h>
00034 #include <App/Document.h>
00035
00036 namespace Base
00037 {
00038 class Matrix4D;
00039 }
00040
00041 namespace Gui {
00042
00043 class ViewProvider;
00044 class ViewProviderDocumentObject;
00045 class Application;
00046 class DocumentPy;
00047
00056 class GuiExport Document : public Base::Persistence
00057 {
00058 public:
00059 Document(App::Document* pcDocument, Application * app);
00060 ~Document();
00061
00062 protected:
00065
00066 void slotNewObject(const App::DocumentObject&);
00067 void slotDeletedObject(const App::DocumentObject&);
00068 void slotChangedObject(const App::DocumentObject&, const App::Property&);
00069 void slotRenamedObject(const App::DocumentObject&);
00070 void slotActivatedObject(const App::DocumentObject&);
00071 void slotRestoredDocument(const App::Document&);
00073
00074 public:
00077
00078 mutable boost::signal<void (const Gui::ViewProviderDocumentObject&)> signalNewObject;
00080 mutable boost::signal<void (const Gui::ViewProviderDocumentObject&)> signalDeletedObject;
00083 mutable boost::signal<void (const Gui::ViewProviderDocumentObject&,
00084 const App::Property&)> signalChangedObject;
00086 mutable boost::signal<void (const Gui::ViewProviderDocumentObject&)> signalRenamedObject;
00088 mutable boost::signal<void (const Gui::ViewProviderDocumentObject&)> signalActivatedObject;
00090 mutable boost::signal<void (const Gui::ViewProviderDocumentObject&)> signalInEdit;
00092 mutable boost::signal<void (const Gui::ViewProviderDocumentObject&)> signalResetEdit;
00094
00097 unsigned int getMemSize (void) const;
00099 bool save(void);
00101 bool saveAs(void);
00103 virtual void Save (Base::Writer &writer) const;
00105 virtual void Restore(Base::XMLReader &reader);
00107 virtual void SaveDocFile (Base::Writer &writer) const;
00109 virtual void RestoreDocFile(Base::Reader &reader);
00110 void exportObjects(const std::vector<App::DocumentObject*>&, Base::Writer&);
00111 void importObjects(const std::vector<App::DocumentObject*>&, Base::Reader&);
00113
00115 void setModified(bool);
00116 bool isModified() const;
00117
00119 App::Document* getDocument(void) const;
00120
00123
00124 Gui::MDIView* getActiveView(void) const;
00126 void createView(const char* sType);
00131
00132 bool sendMsgToViews(const char* pMsg);
00134 void attachView(Gui::BaseView* pcView, bool bPassiv=false);
00136 void detachView(Gui::BaseView* pcView, bool bPassiv=false);
00138 void onUpdate(void);
00140 void onRelabel(void);
00142 std::list<MDIView*> getMDIViews() const;
00144
00147
00148 ViewProvider* getViewProvider(const App::DocumentObject *) const;
00150 void setAnnotationViewProvider(const char* name, ViewProvider *pcProvider);
00152 ViewProvider * getAnnotationViewProvider(const char* name) const;
00154 void removeAnnotationViewProvider(const char* name);
00156 bool isShow(const char* name);
00158 void setShow(const char* name);
00160 void setHide(const char* name);
00162 void setPos(const char* name, const Base::Matrix4D& rclMtrx);
00163 std::vector<ViewProvider*> getViewProvidersOfType(const Base::Type& typeId) const;
00164 ViewProvider *getViewProviderByName(const char* name) const;
00166 bool setEdit(Gui::ViewProvider* p, int ModNum=0);
00168 void resetEdit(void);
00170 ViewProvider *getInEdit(void) const;
00172
00175
00176 void openCommand(const char* sName=0);
00178 void commitCommand(void);
00180 void abortCommand(void);
00182 std::vector<std::string> getUndoVector(void) const;
00184 std::vector<std::string> getRedoVector(void) const;
00186 void undo(int iSteps);
00188 void redo(int iSteps) ;
00190
00192 bool canClose();
00193 bool isLastView(void);
00194
00195 virtual PyObject *getPyObject(void);
00196
00197 protected:
00198
00199 Gui::DocumentPy *_pcDocPy;
00200
00201 private:
00202 struct DocumentP* d;
00203 static int _iDocCount;
00204
00208
00209 std::list<std::string> listUndoNames;
00211 std::list<std::string> listRedoNames;
00213 };
00214
00215 }
00216
00217
00218 #endif // GUI_DOCUMENT_H