/*************************************************************************** begin : jan 02 copyright : (C) 2002 by Pierre Alliez email : pierre.alliez@sophia.inria.fr ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TOOLDOC_H #define TOOLDOC_H #ifdef HAVE_CONFIG_H #include #endif // include files for QT #include #include #include #include #include "enriched_polyhedron.h" // forward declaration of the Tool classes class ToolView; /** ToolDoc provides a document object for a document-view model. * * The ToolDoc class provides a document object that can be used in conjunction with the classes * ToolApp and ToolView to create a document-view model for MDI (Multiple Document Interface) * Qt 2.1 applications based on QApplication and QMainWindow as main classes and QWorkspace as MDI manager widget. * Thereby, the document object is created by the ToolApp instance (and kept in a document list) and contains * the document structure with the according methods for manipulating the document * data by ToolView objects. Also, ToolDoc contains the methods for serialization of the document data * from and to files. * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team. * @version KDevelop version 1.1 code generation */ typedef float number_type; typedef CGAL::Simple_cartesian My_kernel; class ToolDoc : public QObject { Q_OBJECT friend ToolView; private: Enriched_polyhedron *m_pMesh; public: Enriched_polyhedron* mesh() { return m_pMesh; } public: bool m_showNormals; bool m_normalsPerFace; void drawScene( bool move, bool superimposededges = false, bool superimposedvertices = false, bool first = true, bool smooth = false, bool use_normals = true, float r = 1.0f, float g = 1.0f, float b = 1.0f); // TRANSFORM void transformScaleIncrease(); void transformScaleDecrease(); void rescale(); // SUBDIVISION void subdivisionStamLoop(); void subdivisionSqrt3(); void subdivisionSqrt3Twice(); void subdivisionDooSabin(); void subdivisionLoop(); void subdivisionCatmullClark(); // dumping void dumpMesh(); public: /** Constructor for the fileclass of the application */ ToolDoc(); /** Destructor for the fileclass of the application */ ~ToolDoc(); /** adds a view to the document which represents the document contents. Usually this is your main view. */ void addView(ToolView *view); /** removes a view from the list of currently connected views */ void removeView(ToolView *view); /** gets called if a view is removed or added */ void changedViewList(); /** returns the first view instance */ ToolView* firstView() { if(pViewList != NULL) return pViewList->first(); else return NULL; }; /** returns true, if the requested view is the last view of the document */ bool isLastView(); /** This method gets called when the user is about to close a frame window. It checks, if more than one view * is connected to the document (then the frame can be closed), if pFrame is the last view and the document is * modified, the user gets asked if he wants to save the document. */ bool canCloseFrame(ToolView* pFrame); /** sets the modified flag for the document after a modifying action on the view connected to the document.*/ void setModified(bool _m=true){ modified=_m; }; /** returns if the document is modified or not. Use this to determine if your document needs saving by the user on closing.*/ bool isModified(){ return modified; }; /** deletes the document's contents */ void deleteContents(); /** initializes the document generally */ bool newDocument(); /** closes the acutal document */ void closeDocument(); /** loads the document by filename and format and emits the updateViews() signal */ bool openDocument(const QString &filename, const char *format=0); /** saves the document under filename and format.*/ bool saveDocument(const QString &filename, const char *format=0); /** sets the path to the file connected with the document */ void setPathName(const QString &name); /** returns the pathname of the current document file*/ const QString& pathName() const; /** sets the filename of the document */ void setTitle(const QString &title); /** returns the title of the document */ const QString& title() const; public slots: /** calls repaint() on all views connected to the document object and is called by the view by which the document has been changed. * As this view normally repaints itself, it is excluded from the paintEvent. */ void updateAllViews(ToolView *sender); private: /** the modified flag of the current document */ bool modified; QString m_title; QString m_filename; /** the list of the views currently connected to the document */ QList *pViewList; }; #endif // TOOLDOC_H