Developer Documentation
FileOpenVolumeMesh.hh
1 /*===========================================================================*\
2 * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40  \*===========================================================================*/
41 
42 #pragma once
43 
44 #include <QObject>
45 #include <QMenuBar>
46 #include <QComboBox>
47 #include <QCheckBox>
48 
55 #include <OpenFlipper/BasePlugin/INIInterface.hh>
56 
59 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
61 #endif // ENABLE_TETRAHEDRALMESH_SUPPORT
62 #ifndef FILEOPENVOLUMEMESHT_CC
63  #include <OpenVolumeMesh/FileManager/FileManager.hh>
64 #endif
65 
66 class FileOpenVolumeMeshPlugin: public QObject,
72  INIInterface {
73 Q_OBJECT
74 Q_INTERFACES(FileInterface)
75 Q_INTERFACES(LoadSaveInterface)
76 Q_INTERFACES(LoggingInterface)
77 Q_INTERFACES(BaseInterface)
78 Q_INTERFACES(ScriptInterface)
79 Q_INTERFACES(INIInterface)
80  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-FileOVM")
81 public:
82  // Default constructor
84 
85 signals:
86  void openedFile(int _id);
87  void addEmptyObject(DataType _type, int& _id);
88  void load(QString _filename, DataType _type, int& _id);
89  void save(int _id, QString _filename);
90  void log(Logtype _type, QString _message);
91  void log(QString _message);
92 
93  void emptyObjectAdded(int _id);
94 
95  void updateView();
96  void updatedObject(int _id, const UpdateType& _type);
97 
98  void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
99 
100 private slots:
101 
102  void fileOpened(int /*_id*/) {}
103 
104  void loadIniFileLast(INIFile& _ini, int _id);
105  void saveIniFile(INIFile& _ini, int _id);
106 
107  void initializePlugin();
108 
109  void noguiSupported( ) {}
110 
111 public:
112 
114 
115  QString name() {
116  return (QString("FileOpenVolumeMesh"));
117  }
118 
119  QString description() {
120  return (QString(tr("Load/Save OpenVolumeMeshes")));
121  }
122 
124 
125  QString getSaveFilters();
126  QString getLoadFilters();
127 
128  QWidget* saveOptionsWidget(QString _currentFilter);
129  QWidget* loadOptionsWidget(QString _currentFilter);
130 
131 public slots:
132 
133  int loadObject(QString _filename);
134 
135  bool saveObject(int _id, QString _filename);
136 
137  QString version() {
138  return QString("1.0");
139  }
140 
141 private:
142 
143  template <typename MeshT>
144  void loadMesh(const char* _filename, MeshT& _mesh, bool _comp, bool _topCheck);
145 
146  template <typename MeshT>
147  void saveMesh(const char* _filename, MeshT& _mesh, bool _comp);
148 
149 private:
150 
151  QWidget* loadOptions_;
152  QWidget* saveOptions_;
153 
154  QComboBox* typeCheck_;
155 
156  QCheckBox* loadCompMode_;
157  QCheckBox* loadTopCheck_;
158  QCheckBox* saveCompMode_;
159 
160  OpenVolumeMesh::IO::FileManager fileManager_;
161 };
162 
163 #if defined(INCLUDE_TEMPLATES) && !defined(FILEOPENVOLUMEMESHT_CC)
164 #include "FileOpenVolumeMeshT_impl.hh"
165 #endif
166 
Logtype
Log types for Message Window.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
Read/Write mesh data from/to files.
Definition: FileManager.hh:63
QWidget * loadOptionsWidget(QString _currentFilter)
QString name()
Return a name for the plugin.
Update type class.
Definition: UpdateType.hh:59
QString description()
Return a description of what the plugin is doing.
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:60
QWidget * saveOptionsWidget(QString _currentFilter)
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
Interface for all Plugins which provide scriptable Functions.
Interface class from which all plugins have to be created.
Interface class for file handling.
Interface for all plugins which want to Load or Save files and create Objects.