50 #include "Snappy/snappy.h" 62 static const int COLORRANGE_0_1 = 0;
68 template <
typename MeshT>
77 void clear()
override {
82 currentPoint_ = mesh_.add_vertex(_point);
86 mesh_.set_normal( currentPoint_,_normal );
90 mesh_.set_color( currentPoint_,_color );
94 mesh_.set_color( currentPoint_, OpenMesh::color_cast <typename MeshT::Color>(_color));
97 void setPointSize(
float )
override {
101 void setIndex(
int )
override {
105 void request_vertex_normals()
override {
106 mesh_.request_vertex_normals();
109 void request_vertex_colors()
override {
110 mesh_.request_vertex_colors();
113 virtual void request_point_sizes()
override {
117 virtual void request_indices()
override {
121 void reserve(
size_t _size)
override {
122 mesh_.reserve(_size,0,0);
125 virtual DataType adaptorType()
override {
131 typename MeshT::VertexHandle currentPoint_;
141 cloud_.requestPositions();
148 void clear()
override {
150 cloud_.requestPositions();
155 cloud_.pushbackSplat();
156 cloud_.positions( splatIdx_ ) = _point;
160 cloud_.normals( splatIdx_ ) = _normal;
168 cloud_.colors( splatIdx_) = _color;
171 void setPointSize(
float _size )
override {
172 cloud_.pointsizes(splatIdx_) = _size;
175 void setIndex(
int _index )
override {
176 cloud_.indices(splatIdx_) = _index;
179 void request_vertex_normals()
override {
180 cloud_.requestNormals();
183 void request_vertex_colors()
override {
184 cloud_.requestColors();
187 virtual void request_point_sizes()
override {
188 cloud_.requestPointsizes();
191 virtual void request_indices()
override {
192 cloud_.requestIndices();
195 void reserve(
size_t )
override {
198 virtual DataType adaptorType()
override {
209 FilePTSPlugin::FilePTSPlugin() :
210 loadOptions_(
nullptr ),
211 saveOptions_(
nullptr ),
212 saveBinaryFile_(
nullptr ),
213 saveNormals_ (
nullptr ),
214 savePointsizes_(
nullptr ),
215 saveColors_ (
nullptr ),
216 saveColorRange_(
nullptr ),
217 saveIndices_ (
nullptr ),
218 saveMakeDefaultButton_(
nullptr )
223 void FilePTSPlugin::initializePlugin()
226 "This plugin is based on the Snappy compression library by google<br> " 228 "The following license applies to their code: <br> " 229 "Copyright 2005 Google Inc.All Rights Reserved. <br>" 231 "Redistribution and use in source and binary forms, with or without <br>" 232 "modification, are permitted provided that the following conditions are <br>" 235 " *Redistributions of source code must retain the above copyright <br>" 236 "notice, this list of conditions and the following disclaimer. <br>" 237 " * Redistributions in binary form must reproduce the above <br>" 238 "copyright notice, this list of conditions and the following disclaimer <br>" 239 "in the documentation and / or other materials provided with the <br>" 241 " * Neither the name of Google Inc.nor the names of its <br>" 242 "contributors may be used to endorse or promote products derived from <br>" 243 "this software without specific prior written permission. <br>" 245 "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <br>" 246 "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT <br>" 247 "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <br>" 248 "A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT <br>" 249 "OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, <br>" 250 "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT <br>" 251 "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, <br>" 252 "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY <br>" 253 "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT <br>" 254 "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE <br>" 255 "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
257 emit addAboutInfo(info,
"FilePTS");
298 bool FilePTSPlugin::readBinaryFile(
const char *_filename,
SplatCloud &_splatCloud )
312 if( OpenFlipper::Options::gui() && loadOptions_ )
314 loadPositions = loadOptions_->listWidget->findItems(
"Position",Qt::MatchExactly)[0]->isSelected();
315 loadNormals = loadOptions_->listWidget->findItems(
"Normal",Qt::MatchExactly)[0]->isSelected();
316 loadPointsizes = loadOptions_->listWidget->findItems(
"PointSize",Qt::MatchExactly)[0]->isSelected();
317 loadColors = loadOptions_->listWidget->findItems(
"Color",Qt::MatchExactly)[0]->isSelected();
318 loadIndices = loadOptions_->listWidget->findItems(
"Index",Qt::MatchExactly)[0]->isSelected();
324 if( loadNormals ) {
if( !_splatCloud.
requestNormals() ) success =
false; }
326 if( loadColors ) {
if( !_splatCloud.
requestColors() ) success =
false; }
327 if( loadIndices ) {
if( !_splatCloud.
requestIndices() ) success =
false; }
332 emit log(
LOGERR, tr(
"Out of memory for input file \"%1\".\n").arg( _filename ) );
337 FILE *file = fopen( _filename,
"rb" );
340 emit log(
LOGERR, tr(
"Could not open input file \"%1\".\n").arg( _filename ) );
346 fread( &fileType,
sizeof(
int), 1, file );
349 if( fileType != 1 && fileType != 2 && fileType != 3 )
351 emit log(
LOGERR, tr(
"Bad filetype (%1) in input file \"%2\".\n").arg( QString::number( fileType ), _filename ) );
357 unsigned int numSplats = 0;
358 fread( &numSplats,
sizeof(
unsigned int), 1, file );
365 std::vector<ReadObject> readObject = getReadObjectOrder();
367 for (
const ReadObject& element : readObject) {
371 if ( element == PointPos)
374 for (i = 0; i < numSplats; ++i)
377 fread(pos,
sizeof(
float), 3, file);
380 position[0] = pos[0];
381 position[1] = pos[1];
382 position[2] = pos[2];
389 if ( element == PointNormal && loadNormals)
392 for (i = 0; i < numSplats; ++i)
395 fread(nrm,
sizeof(
float), 3, file);
402 _splatCloud.
normals(i) = normal;
407 if (element == PointSize && loadPointsizes)
410 for (i = 0; i < numSplats; ++i)
413 fread(&ps,
sizeof(
float), 1, file);
415 SplatCloud::Pointsize pointsize;
423 if (element == PointColor && loadColors)
426 for (i = 0; i < numSplats; ++i)
428 unsigned int col = 0;
429 fread(&col,
sizeof(
unsigned int), 1, file);
432 color[0] = (
unsigned char)((col >> 16) & 0xFF);
433 color[1] = (
unsigned char)((col >> 8) & 0xFF);
434 color[2] = (
unsigned char)((col) & 0xFF);
436 _splatCloud.
colors(i) = color;
441 if (element == PointIndex && loadIndices)
444 for (i = 0; i < numSplats; ++i)
447 fread(&idx,
sizeof(idx), 1, file);
449 SplatCloud::Index index;
452 _splatCloud.
indices(i) = index;
459 else if (fileType == 3)
463 int numProperties = 0;
464 fread(&numProperties,
sizeof(
int), 1, file);
466 for (
int propID = 0; propID < numProperties; ++propID)
472 fread(&propNameLen,
sizeof(
int), 1, file);
473 std::string propName(propNameLen, 0);
475 fread(&propName[0], 1, propNameLen, file);
479 fread(&dataType,
sizeof(
int), 1, file);
482 quint64 compressedSize = 0;
483 fread(&compressedSize,
sizeof(quint64), 1, file);
484 size_t compressedSizeT =
static_cast<size_t>(compressedSize);
489 if (dataType == SplatDataFileFormat::FLOATVEC3)
491 if (propName ==
"Points")
492 readCompressedBinaryChunk(file, compressedSizeT, reinterpret_cast<char*>(&_splatCloud.
positions(0)));
493 else if (propName ==
"Normals" && loadNormals)
494 readCompressedBinaryChunk(file, compressedSizeT, reinterpret_cast<char*>(&_splatCloud.
normals(0)));
496 fseek(file, static_cast<long>(compressedSizeT), SEEK_CUR);
498 else if (dataType == SplatDataFileFormat::FLOAT)
500 if (propName ==
"Radii" && loadPointsizes)
501 readCompressedBinaryChunk(file, compressedSizeT, reinterpret_cast<char*>(&_splatCloud.
pointsizes(0)));
503 fseek(file, static_cast<long>(compressedSizeT), SEEK_CUR);
505 else if (dataType == SplatDataFileFormat::UINT16)
507 fseek(file, static_cast<long>(compressedSizeT), SEEK_CUR);
509 else if (dataType == SplatDataFileFormat::UINT32)
511 if (propName ==
"Colors" && loadColors)
513 std::vector<ACG::Vec4uc> fileColors(numSplats);
514 readCompressedBinaryChunk(file, compressedSizeT, reinterpret_cast<char*>(&fileColors[0]));
516 for (uint i = 0; i < numSplats; ++i)
518 for (
int k = 0; k < 3; ++k)
519 _splatCloud.
colors(i)[k] = fileColors[i][k];
523 fseek(file, static_cast<long>(compressedSizeT), SEEK_CUR);
525 else if (dataType == SplatDataFileFormat::INT32)
527 fseek(file, static_cast<long>(compressedSizeT), SEEK_CUR);
531 emit log(
LOGWARN, tr(
"Unknown Property type. \"%1\".\n").arg(_filename));
532 fseek(file, static_cast<long>(compressedSizeT), SEEK_CUR);
543 emit log(
LOGERR, tr(
"Could not read input file \"%1\".\n").arg( _filename ) );
549 emit log(
LOGERR, tr(
"Unexpected end in input file \"%1\".\n").arg( _filename ) );
565 std::vector<ReadObject> FilePTSPlugin::getReadObjectOrder() {
567 std::vector<ReadObject> readObject;
569 for (
auto i = 0 ; i < loadOptions_->listWidget->count() ; ++i ) {
570 if ( loadOptions_->listWidget->item(i)->isSelected() ) {
572 if (loadOptions_->listWidget->item(i)->text() ==
"Position" ) {
573 readObject.push_back(PointPos);
576 if (loadOptions_->listWidget->item(i)->text() ==
"Normal" ) {
577 readObject.push_back(PointNormal);
580 if (loadOptions_->listWidget->item(i)->text() ==
"Color" ) {
581 readObject.push_back(PointColor);
584 if (loadOptions_->listWidget->item(i)->text() ==
"PointSize" ) {
585 readObject.push_back(PointSize);
588 if (loadOptions_->listWidget->item(i)->text() ==
"Index" ) {
589 readObject.push_back(PointIndex);
595 for (
const ReadObject& i : readObject) {
598 input_order +=
" Position";
599 if ( i == PointNormal )
600 input_order +=
" Normal";
601 if ( i == PointColor )
602 input_order +=
" Color";
603 if ( i == PointSize )
604 input_order +=
" Pointsize";
605 if ( i == PointIndex )
606 input_order +=
" Index";
609 emit log(
LOGINFO,
"Reading data in this order:" + input_order);
617 bool FilePTSPlugin::readTextFile (
const char *_filename,
AdaptorBase& _adaptor ) {
630 std::vector<ReadObject> readObject = getReadObjectOrder();
633 if ( readObject[0] != PointPos ) {
634 emit log(
LOGERR,
"Position Attribute has to be first in the File!");
641 if( OpenFlipper::Options::gui() && loadOptions_ )
643 loadNormals = loadOptions_->listWidget->findItems(
"Normal",Qt::MatchExactly)[0]->isSelected();
644 loadPointsizes = loadOptions_->listWidget->findItems(
"PointSize",Qt::MatchExactly)[0]->isSelected();
645 loadColors = loadOptions_->listWidget->findItems(
"Color",Qt::MatchExactly)[0]->isSelected();
646 loadIndices = loadOptions_->listWidget->findItems(
"Index",Qt::MatchExactly)[0]->isSelected();
647 pointCount = loadOptions_->pointCount->isChecked();
648 loadColorRange = loadOptions_->comboColor->currentIndex();
653 if( loadNormals ) { _adaptor.request_vertex_normals(); }
654 if( loadColors ) { _adaptor.request_vertex_colors(); }
655 if( loadPointsizes ) { _adaptor.request_point_sizes(); }
656 if( loadIndices ) { _adaptor.request_indices(); }
661 if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
662 emit log(
LOGERR, tr(
"Could not open input file \"%1\".\n").arg( _filename ) );
668 QString line = in.readLine();
673 const int size = line.toInt(&ok);
675 emit log(
LOGINFO, tr(
"Point count in header: \"%1\"").arg( size ) );
676 _adaptor.reserve(size);
678 emit log(
LOGERR, tr(
"Failed to read point count header. Got \"%1\"").arg( line ) );
683 int currentPoint = 0;
685 while (!in.atEnd()) {
687 if ( (currentPoint % 100000) == 0 )
688 emit log(
LOGINFO, tr(
"Reading point %1\n").arg( currentPoint ) );
690 for (
const ReadObject& i : readObject) {
697 in >> pos[0] >> pos[1] >> pos[2];
698 if ( in.status() == QTextStream::Ok ) {
701 emit log(
LOGERR, tr(
"Failed to read postion for point %1\n").arg( currentPoint ) );
707 if( i == PointColor && loadColors )
709 if( loadColorRange == COLORRANGE_0_1 )
713 in >> color[0] >> color[1] >> color[2];
715 if ( in.status() == QTextStream::Ok ) {
716 _adaptor.setColor(color);
718 emit log(
LOGERR, tr(
"Failed to read color for point %1\n").arg( currentPoint ) );
726 in >> col[0] >> col[1] >> col[2];
731 color[0] = (
unsigned char) col[0];
732 color[1] = (
unsigned char) col[1];
733 color[2] = (
unsigned char) col[2];
736 if ( in.status() == QTextStream::Ok ) {
737 _adaptor.setColor(color);
739 emit log(
LOGERR, tr(
"Failed to read color for point %1\n").arg( currentPoint ) );
746 if( i == PointNormal && loadNormals )
749 in >> nrm[0] >> nrm[1] >> nrm[2];
751 if ( in.status() == QTextStream::Ok ) {
757 _adaptor.setNormal(normal);
759 emit log(
LOGERR, tr(
"Failed to read normal for point %1\n").arg( currentPoint ) );
766 if( i == PointSize && loadPointsizes )
773 if ( in.status() == QTextStream::Ok ) {
774 _adaptor.setPointSize(ps);
776 emit log(
LOGERR, tr(
"Failed to read point size for point %1\n").arg( currentPoint ) );
780 emit log(
LOGERR,
"Pointsize not implemented for meshes");
785 if( i == PointNormal && loadIndices )
792 if ( in.status() == QTextStream::Ok ) {
793 _adaptor.setIndex(idx);
795 emit log(
LOGERR, tr(
"Failed to read index for point %1\n").arg( currentPoint ) );
799 emit log(
LOGERR,
"Index not implemented for meshes, skipped");
806 line = in.readLine();
810 if ( in.status() != QTextStream::Ok ) {
811 emit log(
LOGERR, tr(
"Input File Stream Status not ok! Points read: %1\n").arg( currentPoint ) );
816 emit log(
LOGERR, tr(
"Not at end of file! Points read: %1\n").arg( currentPoint ) );
829 bool FilePTSPlugin::writeBinaryFile(
const char *_filename,
const SplatCloudNode *_splatCloudNode )
839 if( OpenFlipper::Options::gui() && saveOptions_ )
841 saveNormals = saveNormals_-> isChecked();
842 savePointsizes = savePointsizes_->isChecked();
843 saveColors = saveColors_-> isChecked();
845 saveIndices = saveIndices_-> isChecked();
862 FILE *file = fopen( _filename,
"wb" );
865 emit log(
LOGERR, tr(
"Could not open output file \"%1\".\n").arg( _filename ) );
871 fwrite( &fileType,
sizeof(
int), 1, file );
874 unsigned int numSplats = _splatCloudNode->splatCloud().
numSplats();
875 fwrite( &numSplats,
sizeof(
unsigned int), 1, file );
880 for( i=0; i<numSplats; ++i )
885 pos[0] = position[0];
886 pos[1] = position[1];
887 pos[2] = position[2];
889 fwrite( pos,
sizeof(
float), 3, file );
897 for( i=0; i<numSplats; ++i )
906 fwrite( nrm,
sizeof(
float), 3, file );
914 for( i=0; i<numSplats; ++i )
916 const SplatCloud::Pointsize &pointsize = _splatCloudNode->getPointsize( i );
921 fwrite( &ps,
sizeof(
float), 1, file );
929 for( i=0; i<numSplats; ++i )
934 col = (0xFF << 24) | (color[0] << 16) | (color[1] << 8) | (color[2]);
936 fwrite( &col,
sizeof(
unsigned int), 1, file );
944 for( i=0; i<numSplats; ++i )
946 const SplatCloud::Index &index = _splatCloudNode->getIndex( i );
951 fwrite( &idx,
sizeof(
int), 1, file );
958 emit log(
LOGERR, tr(
"Could not write output file \"%1\".\n").arg( _filename ) );
974 bool FilePTSPlugin::writeTextFile(
const char *_filename,
const SplatCloudNode *_splatCloudNode )
984 if( OpenFlipper::Options::gui() && saveOptions_ )
986 saveNormals = saveNormals_-> isChecked();
987 savePointsizes = savePointsizes_->isChecked();
988 saveColors = saveColors_-> isChecked();
989 saveColorRange = saveColorRange_->currentIndex();
990 saveIndices = saveIndices_-> isChecked();
994 FILE *file = fopen( _filename,
"wt" );
997 emit log(
LOGERR, tr(
"Could not open output file \"%1\".\n").arg( _filename ) );
1002 unsigned int i, numSplats = _splatCloudNode->splatCloud().
numSplats();
1003 for( i=0; i<numSplats; ++i )
1010 pos[0] = position[0];
1011 pos[1] = position[1];
1012 pos[2] = position[2];
1014 fprintf( file,
"%.6g %.6g %.6g", pos[0], pos[1], pos[2] );
1022 if( saveColorRange == COLORRANGE_0_1 )
1024 static const float RCP255 = 1.0f / 255.0f;
1027 col[0] = RCP255 * color[0];
1028 col[1] = RCP255 * color[1];
1029 col[2] = RCP255 * color[2];
1031 fprintf( file,
" %.6g %.6g %.6g", col[0], col[1], col[2] );
1040 fprintf( file,
" %i %i %i", col[0], col[1], col[2] );
1054 fprintf( file,
" %.6g %.6g %.6g", nrm[0], nrm[1], nrm[2] );
1058 if( savePointsizes )
1060 const SplatCloud::Pointsize &pointsize = _splatCloudNode->getPointsize( i );
1065 fprintf( file,
" %.6g", ps );
1071 const SplatCloud::Index &index = _splatCloudNode->getIndex( i );
1076 fprintf( file,
" %i", idx );
1079 fprintf( file,
"\n" );
1083 if( ferror( file ) )
1085 emit log(
LOGERR, tr(
"Could not write output file \"%1\".\n").arg( _filename ) );
1101 bool FilePTSPlugin::readCompressedBinaryChunk(FILE* _file,
size_t _compressedSize,
char* _dst)
1103 std::vector<char> compressedData(_compressedSize);
1104 fread(&compressedData[0], 1, _compressedSize, _file);
1105 return snappy::RawUncompress(&compressedData[0], _compressedSize, _dst);
1111 int FilePTSPlugin::loadObject( QString _filename )
1115 enum dataType{ splatcloud,
1117 polymesh } loadType = splatcloud;
1119 if( OpenFlipper::Options::gui() && loadOptions_ )
1121 if (loadOptions_->type->currentText() ==
"TriangleMesh") {
1122 loadType = trianglemesh;
1123 }
else if (loadOptions_->type->currentText() ==
"PolyMesh") {
1124 loadType = polymesh;
1126 loadType = splatcloud;
1129 loadBinaryFile = loadOptions_->binary->isChecked();
1133 if ( loadType == splatcloud ) {
1136 int splatCloudObjectId = -1;
1138 if( splatCloudObjectId != -1 )
1142 objectIDs.push_back( splatCloudObjectId );
1155 if( (splatCloud != 0) && (splatCloudNode != 0) )
1160 if( loadBinaryFile ? readBinaryFile( _filename.toLatin1(), *splatCloud ) : readTextFile( _filename.toLatin1(), adaptor ) )
1163 emit updatedObject( splatCloudObjectId,
UPDATE_ALL );
1164 emit openedFile( splatCloudObjectId );
1176 emit log(
LOGERR, tr(
"Shader DrawModes for SplatCloud not existent!") );
1188 drawmode |= pointsDrawMode;
1194 int groupObjectId = RPC::callFunctionValue<int>(
"datacontrol",
"groupObjects", objectIDs );
1195 if( groupObjectId != -1 )
1198 return groupObjectId;
1205 size_t i, num = objectIDs.size();
1206 for( i=0; i<num; ++i )
1207 emit deleteObject( objectIDs[ i ] );
1209 }
else if ( loadType == trianglemesh ) {
1212 int triangleMeshID = -1;
1214 if( triangleMeshID != -1 ) {
1228 if ( loadBinaryFile ) {
1229 emit log(
LOGERR,
"Binary not supported for mesh target!");
1233 readTextFile( _filename.toLatin1(), adaptor ) ;
1236 emit updatedObject( triangleMeshID,
UPDATE_ALL );
1237 emit openedFile( triangleMeshID );
1242 return triangleMeshID;
1250 int polyMeshID = -1;
1252 if( polyMeshID != -1 ) {
1266 if ( loadBinaryFile ) {
1267 emit log(
LOGERR,
"Binary not supported for mesh target!");
1271 readTextFile( _filename.toLatin1(), adaptor ) ;
1274 emit updatedObject( polyMeshID,
UPDATE_ALL );
1275 emit openedFile( polyMeshID );
1295 bool FilePTSPlugin::saveObject(
int _objectId, QString _filename )
1301 if( OpenFlipper::Options::gui() && saveOptions_ )
1303 saveBinaryFile = saveBinaryFile_->isChecked();
1316 if( splatCloudNode != 0 )
1319 if( saveBinaryFile ? writeBinaryFile( _filename.toLatin1(), splatCloudNode ) : writeTextFile( _filename.toLatin1(), splatCloudNode ) )
1337 if ( loadOptions_ ==
nullptr) {
1341 QStringList order =
OpenFlipperSettings().
value(
"FilePTS/Load/Order",
"position,normal,color,size,index" ).toString().split(
",");
1343 loadOptions_->listWidget->clear();
1345 for (
const QString& name : order ) {
1347 if ( name ==
"position" ) {
1348 loadOptions_->listWidget->addItem(
"Position");
1351 if ( name ==
"normal" ) {
1352 loadOptions_->listWidget->addItem(
"Normal");
1355 if ( name ==
"color" ) {
1356 loadOptions_->listWidget->addItem(
"Color");
1359 if ( name ==
"size" ) {
1360 loadOptions_->listWidget->addItem(
"PointSize");
1363 if ( name ==
"index" ) {
1364 loadOptions_->listWidget->addItem(
"Index");
1369 loadOptions_->type->setCurrentIndex (
OpenFlipperSettings().value(
"FilePTS/Load/LoadType", 0 ).toInt() );
1370 loadOptions_->binary->setChecked (
OpenFlipperSettings().value(
"FilePTS/Load/BinaryFile",
true ).toBool() );
1371 loadOptions_->pointCount->setChecked (
OpenFlipperSettings().value(
"FilePTS/Load/PointCount",
true ).toBool() );
1372 loadOptions_->listWidget->findItems(
"Position",Qt::MatchExactly)[0]->setSelected(
OpenFlipperSettings().value(
"FilePTS/Load/Position",
true ).toBool() );
1373 loadOptions_->listWidget->findItems(
"Normal",Qt::MatchExactly)[0]->setSelected(
OpenFlipperSettings().value(
"FilePTS/Load/Normals",
true ).toBool() );
1374 loadOptions_->listWidget->findItems(
"PointSize",Qt::MatchExactly)[0]->setSelected(
OpenFlipperSettings().value(
"FilePTS/Load/Pointsizes",
true ).toBool()) ;
1375 loadOptions_->comboColor->setCurrentIndex(
OpenFlipperSettings().value(
"FilePTS/Load/ColorRange", 0 ).toInt() );
1376 loadOptions_->listWidget->findItems(
"Color",Qt::MatchExactly)[0]->setSelected(
OpenFlipperSettings().value(
"FilePTS/Load/Colors",
true ).toBool()) ;
1377 loadOptions_->listWidget->findItems(
"Index",Qt::MatchExactly)[0]->setSelected(
OpenFlipperSettings().value(
"FilePTS/Load/Indices",
true ).toBool() );
1379 connect(loadOptions_->defaultButton,SIGNAL( clicked() ) ,
this, SLOT(slotLoadMakeDefaultButtonClicked() ) );
1380 connect(loadOptions_->defaultButton,SIGNAL( clicked() ) ,
this, SLOT(slotLoadMakeDefaultButtonClicked() ) );
1384 return loadOptions_;
1393 if( saveOptions_ == 0 )
1397 saveBinaryFile_ =
new QCheckBox( tr(
"Save as Binary File") );
1399 saveNormals_ =
new QCheckBox( tr(
"Save Normals") );
1400 savePointsizes_ =
new QCheckBox( tr(
"Save Pointsizes") );
1401 saveColors_ =
new QCheckBox( tr(
"Save Colors") );
1403 saveColorRange_ =
new QComboBox();
1404 saveColorRange_->addItem(
"[0..1]" );
1405 saveColorRange_->addItem(
"[0..255]" );
1406 slotUpdateSaveColorRange();
1408 QHBoxLayout *saveColorsLayout =
new QHBoxLayout();
1409 saveColorsLayout->setSpacing( 6 );
1410 saveColorsLayout->addWidget( saveColors_ );
1411 saveColorsLayout->addWidget( saveColorRange_ );
1413 saveIndices_ =
new QCheckBox( tr(
"Save Indices") );
1415 QVBoxLayout *saveStructureLayout =
new QVBoxLayout();
1416 saveStructureLayout->setSpacing( 6 );
1417 saveStructureLayout->addWidget( saveNormals_ );
1418 saveStructureLayout->addWidget( savePointsizes_ );
1419 saveStructureLayout->addItem ( saveColorsLayout );
1420 saveStructureLayout->addWidget( saveIndices_ );
1422 QGroupBox *saveStructureGroupBox =
new QGroupBox( tr(
"Internal File Structure") );
1423 saveStructureGroupBox->setLayout( saveStructureLayout );
1425 saveMakeDefaultButton_ =
new QPushButton( tr(
"Make Default") );
1427 QVBoxLayout *saveLayout =
new QVBoxLayout();
1428 saveLayout->setAlignment( Qt::AlignTop );
1429 saveLayout->setSpacing( 6 );
1430 saveLayout->addWidget( saveBinaryFile_ );
1431 saveLayout->addWidget( saveStructureGroupBox );
1432 saveLayout->addWidget( saveMakeDefaultButton_ );
1434 saveOptions_ =
new QWidget();
1435 saveOptions_->setLayout( saveLayout );
1438 connect( saveBinaryFile_, SIGNAL( stateChanged(
int) ),
this, SLOT( slotUpdateSaveColorRange() ) );
1439 connect( saveColors_, SIGNAL( stateChanged(
int) ),
this, SLOT( slotUpdateSaveColorRange() ) );
1440 connect( saveMakeDefaultButton_, SIGNAL( clicked() ),
this, SLOT( slotSaveMakeDefaultButtonClicked() ) );
1443 saveBinaryFile_->setChecked (
OpenFlipperSettings().value(
"FilePTS/Save/BinaryFile",
true ).toBool() );
1444 saveNormals_-> setChecked (
OpenFlipperSettings().value(
"FilePTS/Save/Normals",
true ).toBool() );
1445 savePointsizes_->setChecked (
OpenFlipperSettings().value(
"FilePTS/Save/Pointsizes",
true ).toBool() );
1446 saveColors_-> setChecked (
OpenFlipperSettings().value(
"FilePTS/Save/Colors",
true ).toBool() );
1447 saveColorRange_->setCurrentIndex(
OpenFlipperSettings().value(
"FilePTS/Save/ColorRange", 0 ).toInt() );
1448 saveIndices_-> setChecked (
OpenFlipperSettings().value(
"FilePTS/Save/Indices",
true ).toBool() );
1451 return saveOptions_;
1457 void FilePTSPlugin::slotUpdateSaveColorRange()
1459 saveColorRange_->setEnabled( saveColors_->isChecked() && !saveBinaryFile_->isChecked() );
1466 void FilePTSPlugin::slotLoadMakeDefaultButtonClicked()
1473 OpenFlipperSettings().
setValue(
"FilePTS/Load/Positions", loadOptions_->listWidget->findItems(
"Position",Qt::MatchExactly)[0]->isSelected() );
1474 OpenFlipperSettings().
setValue(
"FilePTS/Load/Normals", loadOptions_->listWidget->findItems(
"Normal",Qt::MatchExactly)[0]->isSelected() );
1475 OpenFlipperSettings().
setValue(
"FilePTS/Load/Pointsizes", loadOptions_->listWidget->findItems(
"PointSize",Qt::MatchExactly)[0]->isSelected() );
1476 OpenFlipperSettings().
setValue(
"FilePTS/Load/Colors", loadOptions_->listWidget->findItems(
"Color",Qt::MatchExactly)[0]->isSelected() );
1478 OpenFlipperSettings().
setValue(
"FilePTS/Load/Indices", loadOptions_->listWidget->findItems(
"Index",Qt::MatchExactly)[0]->isSelected() );
1482 for (
auto i = 0 ; i < loadOptions_->listWidget->count() ; ++i ) {
1483 if (loadOptions_->listWidget->item(i)->text() ==
"Position" ) {
1484 order +=
"position,";
1487 if (loadOptions_->listWidget->item(i)->text() ==
"Normal" ) {
1491 if (loadOptions_->listWidget->item(i)->text() ==
"Color" ) {
1495 if (loadOptions_->listWidget->item(i)->text() ==
"PointSize" ) {
1499 if (loadOptions_->listWidget->item(i)->text() ==
"Index" ) {
1514 void FilePTSPlugin::slotSaveMakeDefaultButtonClicked()
Position & positions(int _idx)
Get a reference of the predefined property's value.
#define DATA_TRIANGLE_MESH
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
unsigned int numSplats() const
Get the number of splats.
Kernel::Normal Normal
Normal type.
Type for a Meshobject containing a poly mesh.
Color & colors(int _idx)
Get a reference of the predefined property's value.
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
bool containsAtomicDrawMode(const DrawMode &_atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
Kernel::Point Point
Coordinate type.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
bool requestPositions()
Request the predefined property.
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
SplatCloud * splatCloud()
Get SplatCloud.
void setName(QString _name)
Set the name of the Object.
QString filename() const
return the filename of the object
MeshT * mesh()
return a pointer to the mesh
std::vector< int > IdList
Standard Type for id Lists used for scripting.
void setName(QString _name)
Set the name of the Object.
bool requestColors()
Request the predefined property.
const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
Normal & normals(int _idx)
Get a reference of the predefined property's value.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
bool requestPointsizes()
Request the predefined property.
Pointsize & pointsizes(int _idx)
Get a reference of the predefined property's value.
bool requestIndices()
Request the predefined property.
DrawMode NONE
not a valid draw mode
Type for a MeshObject containing a triangle mesh.
void clear()
Remove all properties and reset the number of splats.
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
QWidget * loadOptionsWidget(QString)
const Position & getPosition(int _idx) const
if the data array exists, the entry with the given index is returned, otherwise the default value is ...
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
SplatCloudNode * splatCloudNode()
Get SplatCloud's scenegraph Node.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
Index & indices(int _idx)
Get a reference of the predefined property's value.
bool requestNormals()
Request the predefined property.
void resizeSplats(unsigned int _num)
Resize the data vector of all splat-properties.
void setFromFileName(const QString &_filename)
QWidget * saveOptionsWidget(QString)