From f96fe0a647b6aeb571a0046e8d4c14a3d0c9b9b2 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Thu, 14 Jun 2018 15:43:36 +0200 Subject: [PATCH] added separate widgets for assimp loader options and general loader options the widgets use a treewidget to group loader / save options --- .../Plugin-Assimp/AssimpPluginCommon.hh | 61 ++++++ .../widgets/AssimpLoadOpionsWidget.cc | 120 +++++++++++ .../widgets/AssimpLoadOptionsWidget.hh | 66 ++++++ .../widgets/AssimpOpionsWidget.cc | 197 ++++++++++++++++++ .../widgets/AssimpOptionsWidget.hh | 96 +++++++++ .../widgets/AssimpOptionsWidget.ui | 41 ++++ .../widgets/AssimpSaveOpionsWidget.cc | 110 ++++++++++ .../widgets/AssimpSaveOptionsWidget.hh | 64 ++++++ 8 files changed, 755 insertions(+) create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/AssimpPluginCommon.hh create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOpionsWidget.cc create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOptionsWidget.hh create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOpionsWidget.cc create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.hh create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.ui create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOpionsWidget.cc create mode 100644 PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOptionsWidget.hh diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/AssimpPluginCommon.hh b/PluginCollection-FilePlugins/Plugin-Assimp/AssimpPluginCommon.hh new file mode 100644 index 0000000..d84a1aa --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/AssimpPluginCommon.hh @@ -0,0 +1,61 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * +\*===========================================================================*/ + +#pragma once + +// Defines for the type handling drop down box +#define TYPEAUTODETECT 0 +#define TYPEASK 1 +#define TYPEPOLY 2 +#define TYPETRIANGLE 3 + + +struct LoaderOptions +{ + unsigned int triMeshHandling_; + bool loadVertexColorOption_ , loadNormalsOption_ , loadTexCoordsOption_ , loadTexturesOption_, + loadLightsOption_ , loadCamerasOption_ , loadAnimationsOption_; + + LoaderOptions() : triMeshHandling_ (TYPEAUTODETECT) , loadVertexColorOption_(false) , loadNormalsOption_(false) , + loadTexCoordsOption_(false) , loadTexturesOption_ (false) , loadLightsOption_ (false) , + loadCamerasOption_ (false) , loadAnimationsOption_ (false) + {} +}; diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOpionsWidget.cc b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOpionsWidget.cc new file mode 100644 index 0000000..eb73895 --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOpionsWidget.cc @@ -0,0 +1,120 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * +\*===========================================================================*/ + +#include "AssimpLoadOptionsWidget.hh" +#include +#include +#include "../AssimpPluginCommon.hh" + +AssimpLoadOptionsWidget::AssimpLoadOptionsWidget(LoaderOptions & loader, QWidget * parent ) + : AssimpOptionsWidget ("Load", loader, parent) +{ + // generic configuration + triMeshHandling_ = new QComboBox(); + triMeshHandling_->addItem( tr("Detect correct mesh type") ); + triMeshHandling_->addItem( tr("Ask") ); + triMeshHandling_->addItem( tr("Open as PolyMesh") ); + triMeshHandling_->addItem( tr("Open as TriangleMesh") ); + + loadVertexColor_ = new QCheckBox("Load Vertex Colors"); + loadNormals_ = new QCheckBox("Load Vertex Normals"); + loadTexCoords_ = new QCheckBox("Load Vertex Texture Coordinates"); + loadTextures_ = new QCheckBox("Load Textures"); + loadLights_ = new QCheckBox("Load Lights"); + loadCameras_ = new QCheckBox("Load Cameras"); + loadAnimations_ = new QCheckBox("Load Animations"); + +#ifndef ENABLE_LIGHT_SUPPORT + loadLights_->setEnabled(false); +#endif +#ifndef ENABLE_CAMERA_SUPPORT + loadCameras_->setEnabled(false); +#endif +#ifndef ENABLE_SKELETON_SUPPORT + loadAnimations_->setEnabled(false); +#endif + + connect(loadVertexColor_, &QCheckBox::toggled, [&](bool _toggled){loader.loadVertexColorOption_ = _toggled ;}); + connect(loadNormals_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadNormalsOption_ = _toggled ;}); + connect(loadTexCoords_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexCoordsOption_ = _toggled ;}); + connect(loadTextures_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexturesOption_ = _toggled ;}); + connect(loadLights_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadLightsOption_ = _toggled ;}); + connect(loadCameras_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadCamerasOption_ = _toggled ;}); + connect(loadAnimations_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadAnimationsOption_ = _toggled ;}); + + connect(triMeshHandling_ , static_cast(&QComboBox::currentIndexChanged), [&loader](unsigned int _index){loader.triMeshHandling_ = _index;}); + + QList generalOptions = {triMeshHandling_, loadVertexColor_, loadNormals_, loadTexCoords_, + loadTextures_, loadLights_, loadCameras_, loadAnimations_}; + + + QTreeWidgetItem* general = new QTreeWidgetItem(); + general->setText(0,"General"); + tree->invisibleRootItem()->insertChild(0,general); + + + for(QList::iterator it = generalOptions.begin() ; it != generalOptions.end(); ++it) + { + QTreeWidgetItem* treeWidget = new QTreeWidgetItem(); + general->addChild(treeWidget); + tree->setItemWidget(treeWidget,0,*it); + } + + connect(makeDefaultButton_, SIGNAL(clicked()), this, SLOT(slotMakeDefault())); + + triMeshHandling_->setCurrentIndex(OpenFlipperSettings().value("Assimp/Load/TriMeshHandling",TYPEAUTODETECT).toInt() ); + + loadVertexColor_->setChecked( OpenFlipperSettings().value("Assimp/Load/FaceColor",true).toBool() ); + loadNormals_->setChecked ( OpenFlipperSettings().value("Assimp/Load/Normals" ,true).toBool() ); + loadTexCoords_->setChecked( OpenFlipperSettings().value("Assimp/Load/TexCoords",true).toBool() ); + loadTextures_->setChecked ( OpenFlipperSettings().value("Assimp/Load/Textures" ,true).toBool() ); +} + +void AssimpLoadOptionsWidget::slotMakeDefault() +{ + OpenFlipperSettings().setValue( "Assimp/Load/FaceColor", loadVertexColor_->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/Load/Normals", loadNormals_->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/Load/TexCoords", loadTexCoords_->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/Load/Textures", loadTextures_->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/Load/TriMeshHandling", triMeshHandling_->currentIndex() ); + + OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true ); +} diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOptionsWidget.hh b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOptionsWidget.hh new file mode 100644 index 0000000..53c8cfc --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpLoadOptionsWidget.hh @@ -0,0 +1,66 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * +\*===========================================================================*/ + +#pragma once + +#include "AssimpOptionsWidget.hh" + +#include +#include + +struct LoaderOptions; + +class AssimpLoadOptionsWidget : public AssimpOptionsWidget +{ + Q_OBJECT +public: + AssimpLoadOptionsWidget(LoaderOptions& loader, QWidget * parent = 0); + QComboBox *triMeshHandling_; + + QCheckBox * loadVertexColor_ , * loadNormals_ , * loadTexCoords_ , * loadTextures_ , + * loadLights_ , * loadCameras_ , * loadAnimations_ ; + + +private slots: + + void slotMakeDefault(); + +}; diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOpionsWidget.cc b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOpionsWidget.cc new file mode 100644 index 0000000..77fbdc8 --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOpionsWidget.cc @@ -0,0 +1,197 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * +\*===========================================================================*/ + +#include "AssimpOptionsWidget.hh" +#include "ui_AssimpOptionsWidget.hh" +#include +#include +#include "../AssimpPluginCommon.hh" + +AssimpOptionsWidget::AssimpOptionsWidget(const QString & _settingPrefix, LoaderOptions & loader, QWidget * parent ) + : QWidget(parent), + settingPrefix(_settingPrefix) +{ + setupUi(this); + + // setup the treeviewWidget and add an option called advanced for assimp settings + tree->setHeaderLabel("Configuration:"); + QTreeWidgetItem* advanced = new QTreeWidgetItem(); + advanced->setText(0,"Advanced"); + tree->invisibleRootItem()->addChild(advanced); + + //create checkboxes for assimp postprocessing options + option_assimp_process_calcTangentSpace = new QCheckBox("assimp_process_calcTangentSpace "); + option_assimp_process_joinIdenticalVertices = new QCheckBox("assimp_process_joinIdenticalVertices "); + option_assimp_process_makeLeftHanded = new QCheckBox("assimp_process_makeLeftHanded "); + option_assimp_process_triangulate = new QCheckBox("assimp_process_triangulate "); + option_assimp_process_removeComponent = new QCheckBox("assimp_process_removeComponent "); + option_assimp_process_genNormals = new QCheckBox("assimp_process_genNormals "); + option_assimp_process_genSmoothNormals = new QCheckBox("assimp_process_genSmoothNormals "); + option_assimp_process_splitLargeMeshes = new QCheckBox("assimp_process_splitLargeMeshes "); + option_assimp_process_preTransformVertices = new QCheckBox("assimp_process_preTransformVertices "); + option_assimp_process_limitBoneWeights = new QCheckBox("assimp_process_limitBoneWeights "); + option_assimp_process_validateDataStructure = new QCheckBox("assimp_process_validateDataStructure "); + option_assimp_process_improveCacheLocality = new QCheckBox("assimp_process_improveCacheLocality "); + option_assimp_process_removeRedundantMaterials = new QCheckBox("assimp_process_removeRedundantMaterials"); + option_assimp_process_fixInfacingNormals = new QCheckBox("assimp_process_fixInfacingNormals "); + option_assimp_process_sortByPType = new QCheckBox("assimp_process_sortByPType "); + option_assimp_process_findDegenerates = new QCheckBox("assimp_process_findDegenerates "); + option_assimp_process_findInvalidData = new QCheckBox("assimp_process_findInvalidData "); + option_assimp_process_genUVCoords = new QCheckBox("assimp_process_genUVCoords "); + option_assimp_process_transformUVCoords = new QCheckBox("assimp_process_transformUVCoords "); + option_assimp_process_findInstances = new QCheckBox("assimp_process_findInstances "); + option_assimp_process_optimizeMeshes = new QCheckBox("assimp_process_optimizeMeshes "); + option_assimp_process_optimizeGraph = new QCheckBox("assimp_process_optimizeGraph "); + option_assimp_process_flipUVs = new QCheckBox("assimp_process_flipUVs "); + option_assimp_process_flipWindingOrder = new QCheckBox("assimp_process_flipWindingOrder "); + option_assimp_process_splitByBoneCount = new QCheckBox("assimp_process_splitByBoneCount "); + option_assimp_process_debone = new QCheckBox("assimp_process_debone "); + + //store a mapping for each checkbox to a corresponding postprocess setting + loadOptions= {{option_assimp_process_calcTangentSpace , aiProcess_CalcTangentSpace }, + {option_assimp_process_joinIdenticalVertices , aiProcess_JoinIdenticalVertices }, + {option_assimp_process_makeLeftHanded , aiProcess_MakeLeftHanded }, + {option_assimp_process_triangulate , aiProcess_Triangulate }, + {option_assimp_process_removeComponent , aiProcess_RemoveComponent }, + {option_assimp_process_genNormals , aiProcess_GenNormals }, + {option_assimp_process_genSmoothNormals , aiProcess_GenSmoothNormals }, + {option_assimp_process_splitLargeMeshes , aiProcess_SplitLargeMeshes }, + {option_assimp_process_preTransformVertices , aiProcess_PreTransformVertices }, + {option_assimp_process_limitBoneWeights , aiProcess_LimitBoneWeights }, + {option_assimp_process_validateDataStructure , aiProcess_ValidateDataStructure }, + {option_assimp_process_improveCacheLocality , aiProcess_ImproveCacheLocality }, + {option_assimp_process_removeRedundantMaterials, aiProcess_RemoveRedundantMaterials}, + {option_assimp_process_fixInfacingNormals , aiProcess_FixInfacingNormals }, + {option_assimp_process_sortByPType , aiProcess_SortByPType }, + {option_assimp_process_findDegenerates , aiProcess_FindDegenerates }, + {option_assimp_process_findInvalidData , aiProcess_FindInvalidData }, + {option_assimp_process_genUVCoords , aiProcess_GenUVCoords }, + {option_assimp_process_transformUVCoords , aiProcess_TransformUVCoords }, + {option_assimp_process_findInstances , aiProcess_FindInstances }, + {option_assimp_process_optimizeMeshes , aiProcess_OptimizeMeshes }, + {option_assimp_process_optimizeGraph , aiProcess_OptimizeGraph }, + {option_assimp_process_flipUVs , aiProcess_FlipUVs }, + {option_assimp_process_flipWindingOrder , aiProcess_FlipWindingOrder }, + {option_assimp_process_splitByBoneCount , aiProcess_SplitByBoneCount }, + {option_assimp_process_debone , aiProcess_Debone }}; + + //set the Checkboxes as widgets for the treeview items + for(auto it = loadOptions.begin() ; it != loadOptions.end(); ++it) + { + QTreeWidgetItem* treeWidget = new QTreeWidgetItem(); + advanced->addChild(treeWidget); + tree->setItemWidget(treeWidget,0,it->first); + } + + //connect the make default button + connect(makeDefaultButton_, SIGNAL(clicked()), this, SLOT(slotMakeDefault())); + + //initialize checkboxes with stored settings + option_assimp_process_calcTangentSpace ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/calcTangentSpace" , false).toBool()); + option_assimp_process_joinIdenticalVertices ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/joinIdenticalVertices" , true ).toBool()); + option_assimp_process_makeLeftHanded ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/makeLeftHanded" , false).toBool()); + option_assimp_process_triangulate ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/triangulate" , false).toBool()); + option_assimp_process_removeComponent ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/removeComponent" , false).toBool()); + option_assimp_process_genNormals ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/genNormals" , false).toBool()); + option_assimp_process_genSmoothNormals ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/genSmoothNormals" , false).toBool()); + option_assimp_process_splitLargeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/splitLargeMeshes" , false).toBool()); + option_assimp_process_preTransformVertices ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/preTransformVertices" , false).toBool()); + option_assimp_process_limitBoneWeights ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/limitBoneWeights" , false).toBool()); + option_assimp_process_validateDataStructure ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/validateDataStructure" , false).toBool()); + option_assimp_process_improveCacheLocality ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/improveCacheLocality" , false).toBool()); + option_assimp_process_removeRedundantMaterials ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/removeRedundantMaterials", false).toBool()); + option_assimp_process_fixInfacingNormals ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/fixInfacingNormals" , false).toBool()); + option_assimp_process_sortByPType ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/sortByPType" , false).toBool()); + option_assimp_process_findDegenerates ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/findDegenerates" , true ).toBool()); + option_assimp_process_findInvalidData ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/findInvalidData" , false).toBool()); + option_assimp_process_genUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/genUVCoords" , false).toBool()); + option_assimp_process_transformUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/transformUVCoords" , false).toBool()); + option_assimp_process_findInstances ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/findInstances" , false).toBool()); + option_assimp_process_optimizeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/optimizeMeshes" , false).toBool()); + option_assimp_process_optimizeGraph ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/optimizeGraph" , false).toBool()); + option_assimp_process_flipUVs ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/flipUVs" , false).toBool()); + option_assimp_process_flipWindingOrder ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/flipWindingOrder" , false).toBool()); + option_assimp_process_splitByBoneCount ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/splitByBoneCount" , false).toBool()); + option_assimp_process_debone ->setChecked(OpenFlipperSettings().value( "Assimp/"+settingPrefix+"/process/debone" , false).toBool()); +} + +void AssimpOptionsWidget::slotMakeDefault() +{ + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/calcTangentSpace" , option_assimp_process_calcTangentSpace ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/joinIdenticalVertices" , option_assimp_process_joinIdenticalVertices ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/makeLeftHanded" , option_assimp_process_makeLeftHanded ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/triangulate" , option_assimp_process_triangulate ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/removeComponent" , option_assimp_process_removeComponent ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/genNormals" , option_assimp_process_genNormals ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/genSmoothNormals" , option_assimp_process_genSmoothNormals ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/splitLargeMeshes" , option_assimp_process_splitLargeMeshes ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/preTransformVertices" , option_assimp_process_preTransformVertices ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/limitBoneWeights" , option_assimp_process_limitBoneWeights ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/validateDataStructure" , option_assimp_process_validateDataStructure ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/improveCacheLocality" , option_assimp_process_improveCacheLocality ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/removeRedundantMaterials", option_assimp_process_removeRedundantMaterials->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/fixInfacingNormals" , option_assimp_process_fixInfacingNormals ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/sortByPType" , option_assimp_process_sortByPType ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/findDegenerates" , option_assimp_process_findDegenerates ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/findInvalidData" , option_assimp_process_findInvalidData ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/genUVCoords" , option_assimp_process_genUVCoords ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/transformUVCoords" , option_assimp_process_transformUVCoords ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/findInstances" , option_assimp_process_findInstances ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/optimizeMeshes" , option_assimp_process_optimizeMeshes ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/optimizeGraph" , option_assimp_process_optimizeGraph ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/flipUVs" , option_assimp_process_flipUVs ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/flipWindingOrder" , option_assimp_process_flipWindingOrder ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/splitByBoneCount" , option_assimp_process_splitByBoneCount ->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/"+settingPrefix+"/process/debone" , option_assimp_process_debone ->isChecked() ); + + OpenFlipperSettings().setValue( "Core/File/Use"+settingPrefix+"Defaults", true ); +} + +unsigned int AssimpOptionsWidget::processSteps() +{ + unsigned int result = 0; + for(auto entry : loadOptions) + { + if(entry.first != nullptr) + result |= entry.first->isChecked()? entry.second : 0; + } + return result; +} diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.hh b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.hh new file mode 100644 index 0000000..5478036 --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.hh @@ -0,0 +1,96 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * +\*===========================================================================*/ + +#pragma once + +#include "ui_AssimpOptionsWidget.hh" + +#include +#include + +struct LoaderOptions; + +class AssimpOptionsWidget : public QWidget, public Ui::AssimpOptionsWidget +{ + Q_OBJECT + +public: + AssimpOptionsWidget(const QString & _settingPrefix, LoaderOptions& loader, QWidget * parent = 0); + + QString settingPrefix; + + QCheckBox* option_assimp_process_calcTangentSpace ; + QCheckBox* option_assimp_process_joinIdenticalVertices ; + QCheckBox* option_assimp_process_makeLeftHanded ; + QCheckBox* option_assimp_process_triangulate ; + QCheckBox* option_assimp_process_removeComponent ; + QCheckBox* option_assimp_process_genNormals ; + QCheckBox* option_assimp_process_genSmoothNormals ; + QCheckBox* option_assimp_process_splitLargeMeshes ; + QCheckBox* option_assimp_process_preTransformVertices ; + QCheckBox* option_assimp_process_limitBoneWeights ; + QCheckBox* option_assimp_process_validateDataStructure ; + QCheckBox* option_assimp_process_improveCacheLocality ; + QCheckBox* option_assimp_process_removeRedundantMaterials; + QCheckBox* option_assimp_process_fixInfacingNormals ; + QCheckBox* option_assimp_process_sortByPType ; + QCheckBox* option_assimp_process_findDegenerates ; + QCheckBox* option_assimp_process_findInvalidData ; + QCheckBox* option_assimp_process_genUVCoords ; + QCheckBox* option_assimp_process_transformUVCoords ; + QCheckBox* option_assimp_process_findInstances ; + QCheckBox* option_assimp_process_optimizeMeshes ; + QCheckBox* option_assimp_process_optimizeGraph ; + QCheckBox* option_assimp_process_flipUVs ; + QCheckBox* option_assimp_process_flipWindingOrder ; + QCheckBox* option_assimp_process_splitByBoneCount ; + QCheckBox* option_assimp_process_debone ; + + std::unordered_map loadOptions; + + unsigned int processSteps(); + +private slots: + + void slotMakeDefault(); + void slotSaveDefault(); + +}; diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.ui b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.ui new file mode 100644 index 0000000..d64aa0f --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpOptionsWidget.ui @@ -0,0 +1,41 @@ + + + AssimpOptionsWidget + + + + 0 + 0 + 485 + 338 + + + + Property Visualization + + + + + + + + + Configuration: + + + + + + + + Make Default + + + + + + + + + + diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOpionsWidget.cc b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOpionsWidget.cc new file mode 100644 index 0000000..cc4dd40 --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOpionsWidget.cc @@ -0,0 +1,110 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * +\*===========================================================================*/ + +#include "AssimpSaveOptionsWidget.hh" +#include +#include +#include "../AssimpPluginCommon.hh" + +AssimpSaveOptionsWidget::AssimpSaveOptionsWidget(LoaderOptions & loader, QWidget * parent ) + : AssimpOptionsWidget ("Save", loader, parent) +{ + // generic configuration + saveVertexColor_ = new QCheckBox("Save Vertex Colors"); + saveNormals_ = new QCheckBox("Save Vertex Normals"); + saveTexCoords_ = new QCheckBox("Save Vertex Texture Coordinates"); + saveTextures_ = new QCheckBox("Save Textures"); + saveLights_ = new QCheckBox("Save Lights"); + saveCameras_ = new QCheckBox("Save Cameras"); + saveAnimations_ = new QCheckBox("Save Animations"); + +#ifndef ENABLE_LIGHT_SUPPORT + saveLights_->setEnabled(false); +#endif +#ifndef ENABLE_CAMERA_SUPPORT + saveCameras_->setEnabled(false); +#endif +#ifndef ENABLE_SKELETON_SUPPORT + saveAnimations_->setEnabled(false); +#endif + + connect(saveVertexColor_, &QCheckBox::toggled, [&](bool _toggled){loader.loadVertexColorOption_ = _toggled ;}); + connect(saveNormals_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadNormalsOption_ = _toggled ;}); + connect(saveTexCoords_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexCoordsOption_ = _toggled ;}); + connect(saveTextures_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexturesOption_ = _toggled ;}); + connect(saveLights_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadLightsOption_ = _toggled ;}); + connect(saveCameras_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadCamerasOption_ = _toggled ;}); + connect(saveAnimations_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadAnimationsOption_ = _toggled ;}); + + QList generalOptions = {saveVertexColor_, saveNormals_, saveTexCoords_, + saveTextures_ , saveLights_ , saveCameras_ , saveAnimations_}; + + + QTreeWidgetItem* general = new QTreeWidgetItem(); + general->setText(0,"General"); + tree->invisibleRootItem()->insertChild(0,general); + + + for(QList::iterator it = generalOptions.begin() ; it != generalOptions.end(); ++it) + { + QTreeWidgetItem* treeWidget = new QTreeWidgetItem(); + general->addChild(treeWidget); + tree->setItemWidget(treeWidget,0,*it); + } + + connect(makeDefaultButton_, SIGNAL(clicked()), this, SLOT(slotMakeDefault())); + + saveVertexColor_->setChecked( OpenFlipperSettings().value("Assimp/Save/FaceColor",true).toBool() ); + saveNormals_->setChecked ( OpenFlipperSettings().value("Assimp/Save/Normals" ,true).toBool() ); + saveTexCoords_->setChecked ( OpenFlipperSettings().value("Assimp/Save/TexCoords",true).toBool() ); + saveTextures_->setChecked ( OpenFlipperSettings().value("Assimp/Save/Textures" ,true).toBool() ); +} + +void AssimpSaveOptionsWidget::slotMakeDefault() +{ + OpenFlipperSettings().setValue( "Assimp/Save/FaceColor", saveVertexColor_->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/Save/Normals", saveNormals_->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/Save/TexCoords", saveTexCoords_->isChecked() ); + OpenFlipperSettings().setValue( "Assimp/Save/Textures", saveTextures_->isChecked() ); + + OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true ); +} + diff --git a/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOptionsWidget.hh b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOptionsWidget.hh new file mode 100644 index 0000000..930c3e1 --- /dev/null +++ b/PluginCollection-FilePlugins/Plugin-Assimp/widgets/AssimpSaveOptionsWidget.hh @@ -0,0 +1,64 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (c) 2001-2015, RWTH-Aachen University * + * Department of Computer Graphics and Multimedia * + * All rights reserved. * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + *---------------------------------------------------------------------------* + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. Neither the name of the copyright holder nor the names of its * + * contributors may be used to endorse or promote products derived from * + * this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * +\*===========================================================================*/ + +#pragma once + +#include "AssimpOptionsWidget.hh" + +#include +#include + +struct LoaderOptions; + +class AssimpSaveOptionsWidget : public AssimpOptionsWidget +{ + Q_OBJECT +public: + AssimpSaveOptionsWidget(LoaderOptions& loader, QWidget * parent = 0); + + QCheckBox * saveVertexColor_ , * saveNormals_ , * saveTexCoords_ , * saveTextures_ , + * saveLights_ , * saveCameras_ , * saveAnimations_ ; + + +private slots: + + void slotMakeDefault(); +}; -- 2.22.0