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 #pragma once
56 
57 
58 //== INCLUDES ====================================================
59 
60 
61 #include <QObject>
62 
70 
72 
76 
77 #include <QComboBox>
78 #include <QCheckBox>
79 #include <QLayout>
80 #include <QHBoxLayout>
81 #include <QGroupBox>
82 #include <QPushButton>
83 
84 #include "ui_ptsLoadWidget.h"
85 
86 //== CLASS DEFINITION ============================================
87 
88 class AdaptorBase {
89 
90 public:
91  virtual void clear() = 0;
92  virtual void add_point(ACG::Vec3d _point) = 0;
93  virtual void setNormal(ACG::Vec3d _normal) = 0;
94  virtual void setColor(ACG::Vec4f _color) = 0;
95  virtual void setColor(ACG::Vec3uc _color) = 0;
96  virtual void setPointSize(float _size ) = 0;
97  virtual void setIndex(int _index ) = 0;
98 
99  virtual void request_vertex_normals() = 0;
100  virtual void request_vertex_colors() = 0;
101  virtual void request_point_sizes() = 0;
102  virtual void request_indices() = 0;
103 
104  virtual void reserve(size_t _size) = 0;
105 
106  virtual DataType adaptorType() = 0;
107 };
108 
109 class ptsLoadWiget : public QWidget, public Ui::ptsLoadWidget
110 {
111  Q_OBJECT
112 
113  public:
114  explicit ptsLoadWiget(QWidget *parent = 0) : QWidget(parent) { setupUi(this); };
115 };
116 
118 enum ReadObject{ PointPos,PointNormal,PointColor,PointSize,PointIndex };
119 
121 {
122  Q_OBJECT
123  Q_INTERFACES( FileInterface )
124  Q_INTERFACES( LoadSaveInterface )
125  Q_INTERFACES( LoggingInterface )
126  Q_INTERFACES( BaseInterface )
127  Q_INTERFACES( ScriptInterface )
128  Q_INTERFACES( RPCInterface )
129  Q_INTERFACES( AboutInfoInterface )
130 
131  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-FilePTS")
132 
133 signals:
134 
135  // -- File Interface --
136  void openedFile( int _objectId );
137 
138  // -- LoadSave Interface --
139  void addEmptyObject( DataType _type, int &_objectId );
140  void deleteObject ( int _objectId );
141  void updatedObject( int _objectId, const UpdateType &_type );
142 
143  //-- Logging Interface --
144  void log( QString _message );
145  void log( Logtype _type, QString _message );
146 
147  //-- AboutInfoInterface --
148  void addAboutInfo(QString _text, QString _tabName);
149 
150 private slots:
151 
152  // -- Base Interface --
153  void initializePlugin();
154  void noguiSupported() { }
155 
156 public:
157 
158  // standard constructor/destructor
159  FilePTSPlugin();
160  ~FilePTSPlugin() { }
161 
162  //-- Base Interface --
163  QString name() { return QString( "FilePTS" ); }
164  QString description( ) { return QString( tr("Load/Save SplatCloud format files") ); }
165 
166  // -- File Interface --
168 
169  // -- File Interface --
170  QString getSaveFilters() { return QString( tr("SplatCloud format files ( *.pts *.bin )") ); }
171  QString getLoadFilters() { return QString( tr("SplatCloud format files ( *.pts *.bin )") ); }
172  QWidget *saveOptionsWidget( QString /*_currentFilter*/ );
173  QWidget *loadOptionsWidget( QString /*_currentFilter*/ );
174 
175 public slots:
176 
177  // -- Base Interface --
178  QString version() { return QString( "1.0" ); }
179 
180  // -- File Interface --
181  int loadObject( QString _filename );
182  bool saveObject( int _objectId, QString _filename );
183 
184 private:
185 
186  // read binary/text file from disc to scenegraph node
187  bool readBinaryFile( const char *_filename, SplatCloud &_splatCloud ) /*const*/;
188 
189  bool readTextFile ( const char *_filename, AdaptorBase& _adaptor );
190 
191  // write binary/text file from scenegraph node to disc
192  bool writeBinaryFile( const char *_filename, const SplatCloudNode *_splatCloudNode ) /*const*/;
193  bool writeTextFile ( const char *_filename, const SplatCloudNode *_splatCloudNode ) /*const*/;
194 
195  // read and decompress a binary chunk from file stream (snappy compression)
196  bool readCompressedBinaryChunk( FILE* _file, size_t _compressedSize, char* _dst );
197 
198  // Get a read Object Order from ui
199  std::vector<ReadObject> getReadObjectOrder();
200 
201  // widgets
202  ptsLoadWiget *loadOptions_;
203  QWidget *saveOptions_;
204 
205  // options in the saving menu
206  QCheckBox *saveBinaryFile_;
207  QCheckBox *saveNormals_;
208  QCheckBox *savePointsizes_;
209  QCheckBox *saveColors_;
210  QComboBox *saveColorRange_;
211  QCheckBox *saveIndices_;
212 
213  // buttons
214  QPushButton *saveMakeDefaultButton_;
215 
216 private slots:
217 
218  // slots called when the Load/Save colors checkbox or binaryfile checkbox was clicked
219  void slotUpdateSaveColorRange();
220 
221  // slots called when user wants to save the given Load/Save Options as default
222  void slotLoadMakeDefaultButtonClicked();
223  void slotSaveMakeDefaultButtonClicked();
224 };
225 
226 
227 //================================================================
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FilePTS.hh:167
QString getLoadFilters()
Definition: FilePTS.hh:171
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:163
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
QString getSaveFilters()
Definition: FilePTS.hh:170
Update type class.
Definition: UpdateType.hh:59
QString description()
Return a description of what the plugin is doing.
Definition: FilePTS.hh:164
About Info interface.
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.