FileInterface.hh 7.12 KB
 Jan Möbius committed Aug 05, 2009 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 ``````/*===========================================================================*\ * * * OpenFlipper * * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * * www.openflipper.org * * * *---------------------------------------------------------------------------* * This file is part of OpenFlipper. * * * * OpenFlipper is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation, either version 3 of * * the License, or (at your option) any later version with the * * following exceptions: * * * * If other files instantiate templates or use macros * * or inline functions from this file, or you compile this file and * * link it with other files to produce an executable, this file does * * not by itself cause the resulting executable to be covered by the * * GNU Lesser General Public License. This exception does not however * * invalidate any other reasons why the executable file might be * * covered by the GNU Lesser General Public License. * * * * OpenFlipper is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU LesserGeneral Public * * License along with OpenFlipper. If not, * * see . * * * \*===========================================================================*/ /*===========================================================================*\ * * * \$Revision\$ * * \$Author\$ * * \$Date\$ * * * \*===========================================================================*/ `````` Jan Möbius committed Aug 29, 2008 42 43 44 45 46 47 48 `````` // // C++ Interface: BasePlugin // `````` Jan Möbius committed Sep 16, 2008 49 ``````// Description: `````` Jan Möbius committed Aug 29, 2008 50 51 52 53 54 ``````// // // Author: Jan Moebius , (C) 2007 // `````` Jan Möbius committed Sep 16, 2008 55 56 ``````#ifndef FILEINTERFACE_HH #define FILEINTERFACE_HH `````` Jan Möbius committed Aug 29, 2008 57 58 59 `````` #include #include `````` Jan Möbius committed Sep 16, 2008 60 `````` `````` Jan Möbius committed Aug 29, 2008 61 `````` /** \brief Interface class for file and object handling `````` Jan Möbius committed Sep 16, 2008 62 63 `````` * * This interface class has to be fully implemented. When you want to support save and load `````` Jan Möbius committed Aug 29, 2008 64 65 66 67 68 69 70 `````` * for an object type you have to implement all functions in this class. The core manages the * load and save interaction and gives the load and save actions to your plugin. The decision * which plugin is called for saving an object depends on your supportedTypes() and the filters * defined by your plugin. */ class FileInterface { `````` Jan Möbius committed Sep 16, 2008 71 `````` `````` Jan Möbius committed Feb 03, 2009 72 73 74 75 ``````//=========================================================================== /** @name Widgets * @{ */ //=========================================================================== `````` Mike Kremer committed Feb 10, 2009 76 77 78 79 `````` public: /// Destructor virtual ~FileInterface() {}; `````` Dirk Wilden committed Sep 15, 2008 80 `````` `````` Jan Möbius committed Feb 03, 2009 81 82 83 84 85 86 87 88 `````` /** You can provide a special widget showing options for saving your file types * depending on the current filter * * _currentFilter: one filter from saveFilters * * Return 0 when you dont need one */ virtual QWidget* saveOptionsWidget(QString /*_currentFilter*/) = 0; `````` Dirk Wilden committed Sep 15, 2008 89 `````` `````` Jan Möbius committed Feb 03, 2009 90 91 92 93 94 95 96 97 `````` /** You can provide a special widget showing options for loading your file types * depending on the current filter * * _currentFilter: one filter from loadFilters * * Return 0 when you dont need one */ virtual QWidget* loadOptionsWidget(QString /*_currentFilter*/) = 0; `````` Jan Möbius committed Feb 03, 2009 98 99 `````` /** @} */ `````` Jan Möbius committed Sep 16, 2008 100 `````` `````` Jan Möbius committed Feb 03, 2009 101 102 103 104 105 106 107 ``````//=========================================================================== /** @name Supported types * @{ */ //=========================================================================== public: `````` Jan Möbius committed Nov 30, 2009 108 `````` /** \brief Return your supported object type( e.g. DATA_TRIANGLE_MESH ) `````` Jan Möbius committed Feb 03, 2009 109 `````` * `````` Jan Möbius committed Nov 30, 2009 110 111 112 `````` * If you support multiple datatypes you can use the bitwise or to combine them here. * The function is used from addEmpty to check if your plugin can create an object of * a given dataType. `````` Jan Möbius committed Feb 03, 2009 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 `````` */ virtual DataType supportedType() = 0; /** Return the Qt Filters for Filedialogs when loading files (e.g. "Off files ( *.off )" ) * */ virtual QString getLoadFilters() = 0; /** Get the Qt Filters for Filedialogs when saving files (e.g. "Off files ( *.off )" ) * */ virtual QString getSaveFilters() = 0; /** @} */ //=========================================================================== /** @name Load Save Implementation * @{ */ //=========================================================================== `````` Jan Möbius committed Sep 16, 2008 134 135 ``````public slots: `````` Jan Möbius committed Feb 03, 2009 136 137 138 139 `````` /** \brief Create an empty object * * When this slot is called you have to create an object of your supported type. * @return Id of the new Object `````` Jan Möbius committed Nov 26, 2009 140 141 `````` * \todo Add an addEmpty function with a given type as an attribute. The plugin should then create only an * empty object of the given type. It can be assumed that there is only one type given at a time. `````` Jan Möbius committed Feb 03, 2009 142 143 `````` */ virtual int addEmpty() = 0; `````` Jan Möbius committed Nov 26, 2009 144 `````` `````` Jan Möbius committed Feb 03, 2009 145 146 147 148 `````` /** \brief Load an object from the given file * * The Core will call this slot if you should load a file. The core will * check if you support the given file type depending on the provided `````` Jan Möbius committed Nov 27, 2009 149 150 151 152 153 `````` * filters and dataTypes ( see supportedType and getLoadFilters )\n * * if you just opened a file and did not create any object, return 0 here, * telling the core that it was successfully loaded but no new object * has been created! `````` Jan Möbius committed Feb 03, 2009 154 `````` */ `````` Dirk Wilden committed Sep 30, 2008 155 `````` virtual int loadObject(QString /*_filename*/) = 0; `````` Jan Möbius committed Sep 16, 2008 156 `````` `````` Jan Möbius committed Feb 03, 2009 157 158 159 160 161 162 163 `````` /** \brief Save an object from the given file * * The Core will call this slot if you should save an object to a file. * The core will check if you support the given object depending on the * provided dataTypes ( see supportedType ). * Additionally to the filename you get the id of the object to save */ `````` Dirk Wilden committed Sep 30, 2008 164 `````` virtual bool saveObject(int /*_id*/, QString /*_filename*/) = 0; `````` Jan Möbius committed Sep 16, 2008 165 `````` `````` Jan Möbius committed Feb 03, 2009 166 ``````/** @} */ `````` Jan Möbius committed Sep 16, 2008 167 `````` `````` Jan Möbius committed Aug 29, 2008 168 169 170 ``````}; Q_DECLARE_INTERFACE(FileInterface,"OpenFlipper.FileInterface/0.3") `````` Jan Möbius committed Sep 16, 2008 171 `````` `````` Jan Möbius committed Aug 29, 2008 172 ``#endif // FILEINTERFACE_HH``