Developer Documentation
FilePTS.hh
1 //================================================================
2 //
3 /*===========================================================================*\
4 * *
5 * OpenFlipper *
6  * Copyright (c) 2001-2015, RWTH-Aachen University *
7  * Department of Computer Graphics and Multimedia *
8  * All rights reserved. *
9  * www.openflipper.org *
10  * *
11  *---------------------------------------------------------------------------*
12  * This file is part of OpenFlipper. *
13  *---------------------------------------------------------------------------*
14  * *
15  * Redistribution and use in source and binary forms, with or without *
16  * modification, are permitted provided that the following conditions *
17  * are met: *
18  * *
19  * 1. Redistributions of source code must retain the above copyright notice, *
20  * this list of conditions and the following disclaimer. *
21  * *
22  * 2. Redistributions in binary form must reproduce the above copyright *
23  * notice, this list of conditions and the following disclaimer in the *
24  * documentation and/or other materials provided with the distribution. *
25  * *
26  * 3. Neither the name of the copyright holder nor the names of its *
27  * contributors may be used to endorse or promote products derived from *
28  * this software without specific prior written permission. *
29  * *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
31  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
32  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
33  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
34  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
35  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
36  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
37  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
38  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
39  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
40  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
41 * *
42 \*===========================================================================*/
43 
44 
45 
46 
47 //================================================================
48 //
49 // CLASS FilePTSPlugin
50 //
51 // This class is the base class for loading and saving (reading/writing) SplatCloud objects from/to disc.
52 //
53 //================================================================
54 
55 
56 #ifndef FILEPTSPLUGIN_HH
57 #define FILEPTSPLUGIN_HH
58 
59 
60 //== INCLUDES ====================================================
61 
62 
63 #include <QObject>
64 class QCheckBox;
65 class QComboBox;
66 class QPushButton;
67 
75 
77 
79 
80 
81 //== CLASS DEFINITION ============================================
82 
83 
85 {
86  Q_OBJECT
87  Q_INTERFACES( FileInterface )
88  Q_INTERFACES( LoadSaveInterface )
89  Q_INTERFACES( LoggingInterface )
90  Q_INTERFACES( BaseInterface )
91  Q_INTERFACES( ScriptInterface )
92  Q_INTERFACES( RPCInterface )
93  Q_INTERFACES( AboutInfoInterface )
94  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-FilePTS")
95 signals:
96 
97  // -- File Interface --
98  void openedFile( int _objectId );
99 
100  // -- LoadSave Interface --
101  void addEmptyObject( DataType _type, int &_objectId );
102  void deleteObject ( int _objectId );
103  void updatedObject( int _objectId, const UpdateType &_type );
104 
105  //-- Logging Interface --
106  void log( QString _message );
107  void log( Logtype _type, QString _message );
108 
109  //-- AboutInfoInterface --
110  void addAboutInfo(QString _text, QString _tabName);
111 
112 private slots:
113 
114  // -- Base Interface --
115  void initializePlugin();
116  void noguiSupported() { }
117 
118 public:
119 
120  // standard constructor/destructor
121  FilePTSPlugin();
122  ~FilePTSPlugin() { }
123 
124  //-- Base Interface --
125  QString name() { return QString( "FilePTS" ); }
126  QString description( ) { return QString( tr("Load/Save SplatCloud format files") ); }
127 
128  // -- File Interface --
130 
131  // -- File Interface --
132  QString getSaveFilters() { return QString( tr("SplatCloud format files ( *.pts *.bin )") ); }
133  QString getLoadFilters() { return QString( tr("SplatCloud format files ( *.pts *.bin )") ); }
134  QWidget *saveOptionsWidget( QString /*_currentFilter*/ );
135  QWidget *loadOptionsWidget( QString /*_currentFilter*/ );
136 
137 public slots:
138 
139  // -- Base Interface --
140  QString version() { return QString( "1.0" ); }
141 
142  // -- File Interface --
143  int loadObject( QString _filename );
144  bool saveObject( int _objectId, QString _filename );
145 
146 private:
147 
148  // read binary/text file from disc to scenegraph node
149  bool readBinaryFile( const char *_filename, SplatCloud &_splatCloud ) /*const*/;
150  bool readTextFile ( const char *_filename, SplatCloud &_splatCloud ) /*const*/;
151 
152  // write binary/text file from scenegraph node to disc
153  bool writeBinaryFile( const char *_filename, const SplatCloudNode *_splatCloudNode ) /*const*/;
154  bool writeTextFile ( const char *_filename, const SplatCloudNode *_splatCloudNode ) /*const*/;
155 
156  // read and decompress a binary chunk from file stream (snappy compression)
157  bool readCompressedBinaryChunk( FILE* _file, size_t _compressedSize, char* _dst );
158 
159 
160  // widgets
161  QWidget *loadOptions_;
162  QWidget *saveOptions_;
163 
164  // options in the loading menu
165  QCheckBox *loadBinaryFile_;
166  QCheckBox *loadNormals_;
167  QCheckBox *loadPointsizes_;
168  QCheckBox *loadColors_;
169  QComboBox *loadColorRange_;
170  QCheckBox *loadIndices_;
171 
172  // options in the saving menu
173  QCheckBox *saveBinaryFile_;
174  QCheckBox *saveNormals_;
175  QCheckBox *savePointsizes_;
176  QCheckBox *saveColors_;
177  QComboBox *saveColorRange_;
178  QCheckBox *saveIndices_;
179 
180  // buttons
181  QPushButton *loadMakeDefaultButton_;
182  QPushButton *saveMakeDefaultButton_;
183 
184 private slots:
185 
186  // slots called when the Load/Save colors checkbox or binaryfile checkbox was clicked
187  void slotUpdateLoadColorRange();
188  void slotUpdateSaveColorRange();
189 
190  // slots called when user wants to save the given Load/Save Options as default
191  void slotLoadMakeDefaultButtonClicked();
192  void slotSaveMakeDefaultButtonClicked();
193 };
194 
195 
196 //================================================================
197 
198 
199 #endif // FILEPTSPLUGIN_HH
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FilePTS.hh:129
QString getLoadFilters()
Definition: FilePTS.hh:133
Logtype
Log types for Message Window.
#define DATA_SPLATCLOUD
Definition: SplatCloud.hh:59
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
QString name()
Return a name for the plugin.
Definition: FilePTS.hh:125
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
QString getSaveFilters()
Definition: FilePTS.hh:132
Update type class.
Definition: UpdateType.hh:60
QString description()
Return a description of what the plugin is doing.
Definition: FilePTS.hh:126
About Info interface.
QWidget * loadOptionsWidget(QString)
Definition: FilePTS.cc:1029
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.
QWidget * saveOptionsWidget(QString)
Definition: FilePTS.cc:1096