From 03d55fd7b9e46c20bded87b5479385b155ccde52 Mon Sep 17 00:00:00 2001 From: Isaak Lim Date: Fri, 8 Jul 2016 14:32:18 +0200 Subject: [PATCH 1/3] always set a newly created object (via addEmpty) to be target for most types --- .../Plugin-TypeBSplineCurve/TypeBSplineCurve.cc | 6 +----- .../Plugin-TypeBSplineSurface/TypeBSplineSurface.cc | 6 +----- .../Plugin-TypeCamera/TypeCamera.cc | 5 +---- .../Plugin-TypeCoordsys/TypeCoordsys.cc | 6 +----- .../Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc | 6 +----- PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc | 6 +----- .../Plugin-TypePolyLine/TypePolyLine.cc | 6 +----- .../Plugin-TypePolyMesh/TypePolyMesh.cc | 6 +----- .../Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc | 6 +----- .../Plugin-TypeSkeleton/TypeSkeleton.cc | 6 +----- .../Plugin-TypeSphere/TypeSphere.cc | 6 +----- .../Plugin-TypeSplatCloud/TypeSplatCloud.cc | 6 +----- .../Plugin-TypeTriangleMesh/TypeTriangleMesh.cc | 6 +----- 13 files changed, 13 insertions(+), 64 deletions(-) diff --git a/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc b/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc index ac2e06739..f052af64d 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc @@ -274,11 +274,7 @@ addEmpty() // new object data struct BSplineCurveObject * object = new BSplineCurveObject(); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = "BSplineCurve_" + QString::number( object->id() ) + ".bsc"; diff --git a/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc b/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc index a8f4a4868..816542d4c 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc @@ -272,11 +272,7 @@ addEmpty() // new object data struct BSplineSurfaceObject * object = new BSplineSurfaceObject(); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = "BSplineSurface_" + QString::number( object->id() ) + ".bss"; diff --git a/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc b/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc index cf3c5c217..37e18d6f7 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc @@ -116,10 +116,7 @@ int TypeCameraPlugin::addEmpty() { // new object data struct CameraObject* object = new CameraObject (); - if ( PluginFunctions::objectCount() == 1 || - PluginFunctions::targetCount() == 0) { - object->target ( true ); - } + object->target ( true ); QString name = QString(tr("New Camera %1.cam").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc b/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc index fcb362115..ed6c4981c 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc @@ -65,11 +65,7 @@ int TypeCoordsysPlugin::addEmpty(){ // new object data struct CoordsysObject * object = new CoordsysObject(); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = QString(tr("New Coordinate System %1.cos").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc b/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc index 53f541a20..389f2e461 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc @@ -103,11 +103,7 @@ int TypeHexahedralMeshPlugin::addEmpty() { // New object data struct HexahedralMeshObject* object = new HexahedralMeshObject(DATA_HEXAHEDRAL_MESH); - if (PluginFunctions::objectCount() == 1) - object->target(true); - - if (PluginFunctions::targetCount() == 0) - object->target(true); + object->target(true); QString name = QString(tr("New Hexahedral Mesh %1.ovm").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc b/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc index a2202fd3a..5631e8588 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc @@ -69,11 +69,7 @@ int TypePlanePlugin::addEmpty(){ // new object data struct PlaneObject * object = new PlaneObject(); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = QString(tr("New Plane %1.pla").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc b/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc index f5c99e291..d456a549f 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc @@ -67,12 +67,8 @@ int TypePolyLinePlugin::addEmpty(){ // new object data struct PolyLineObject * object = new PolyLineObject(); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); + object->target(true); - if (PluginFunctions::targetCount() == 0 ) - object->target(true); - QString name = tr("New PolyLine %1.pol").arg( object->id() ); // call the local function to update names diff --git a/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc b/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc index 046aab1eb..7c5d929f9 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc @@ -75,11 +75,7 @@ int TypePolyMeshPlugin::addEmpty(){ // new object data struct PolyMeshObject * object = new PolyMeshObject( typeId("PolyMesh") ); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = QString(tr("New PolyMesh %1.off").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc b/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc index 9e8c4a6d0..4beab353f 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc @@ -111,11 +111,7 @@ int TypePolyhedralMeshPlugin::addEmpty() { // new object data struct PolyhedralMeshObject* object = new PolyhedralMeshObject(DATA_POLYHEDRAL_MESH); - if (PluginFunctions::objectCount() == 1) - object->target(true); - - if (PluginFunctions::targetCount() == 0) - object->target(true); + object->target(true); QString name = QString(tr("New PolyHedral Mesh %1.ovm").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc b/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc index 736c4580f..b16c312ad 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc @@ -193,11 +193,7 @@ int TypeSkeletonPlugin::addEmpty(){ // new object data struct SkeletonObject * object = new SkeletonObject(); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = QString(tr("New Skeleton %1.skl").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc b/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc index 7fb0f6c74..e37a91966 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc @@ -70,11 +70,7 @@ int TypeSpherePlugin::addEmpty(){ // new object data struct SphereObject * object = new SphereObject(); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = QString(tr("New Sphere %1.sph").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc b/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc index f22bf60c1..b258ce130 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc @@ -296,11 +296,7 @@ int TypeSplatCloudPlugin::addEmpty() if( object == 0 ) return -1; - if( PluginFunctions::objectCount() == 1 ) - object->target( true ); - - if( PluginFunctions::targetCount() == 0 ) - object->target( true ); + object->target( true ); QString name = QString(tr("New Splat Cloud %1.spl").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc b/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc index 16804f21f..b2a9cde08 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc @@ -74,11 +74,7 @@ int TypeTriangleMeshPlugin::addEmpty(){ // new object data struct TriMeshObject * object = new TriMeshObject( typeId("TriangleMesh") ); - if ( PluginFunctions::objectCount() == 1 ) - object->target(true); - - if (PluginFunctions::targetCount() == 0 ) - object->target(true); + object->target(true); QString name = QString(tr("TriangleMesh new %1.off").arg( object->id() )); -- GitLab From 8053095bf8b2a47994f61ceb183e1cd1e2c57022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 11 Jul 2016 08:37:34 +0200 Subject: [PATCH 2/3] Added option to change default behaviour on newly created objects with target setting --- .../widgets/optionsWidget/optionsWidget.cc | 4 ++ .../widgets/optionsWidget/optionsWidget.ui | 37 +++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/OpenFlipper/widgets/optionsWidget/optionsWidget.cc b/OpenFlipper/widgets/optionsWidget/optionsWidget.cc index a89b8a751..5ac32fd14 100644 --- a/OpenFlipper/widgets/optionsWidget/optionsWidget.cc +++ b/OpenFlipper/widgets/optionsWidget/optionsWidget.cc @@ -273,6 +273,8 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) { maxRecentBox->setValue( OpenFlipperSettings().value("Core/File/MaxRecent",15).toInt() ); rbReloadShaders->setChecked(OpenFlipperSettings().value("Core/File/ReloadShaders",false).toBool()) ; leShaderOutputDir->setText(OpenFlipperSettings().value("Core/File/ShaderOutputDir","").toString()); + allTarget->setChecked( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ); + // UI settings toolBoxOrientation->setCurrentIndex((OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool() ? 0 : 1)); @@ -584,6 +586,8 @@ void OptionsWidget::slotApply() { OpenFlipperSettings().setValue("Core/File/ShaderOutputDir",leShaderOutputDir->text() ) ; ACG::ShaderCache::getInstance()->setDebugOutputDir(leShaderOutputDir->text().toUtf8()); + OpenFlipperSettings().setValue("Core/File/AllTarget",allTarget->isChecked()); + // Toolbox orientation OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight", (toolBoxOrientation->currentIndex() == 0)); diff --git a/OpenFlipper/widgets/optionsWidget/optionsWidget.ui b/OpenFlipper/widgets/optionsWidget/optionsWidget.ui index b6278e7e4..0028d16bf 100644 --- a/OpenFlipper/widgets/optionsWidget/optionsWidget.ui +++ b/OpenFlipper/widgets/optionsWidget/optionsWidget.ui @@ -6,7 +6,7 @@ 0 0 - 699 + 702 700 @@ -36,8 +36,8 @@ 0 0 - 662 - 862 + 721 + 957 @@ -50,7 +50,7 @@ - 1 + 0 true @@ -412,6 +412,35 @@ + + + + General Object Options + + + + + + + + The add empty object functions will set all new objects to be target by default + + + The add empty object functions will set all new objects to be target by default + + + The add empty object functions will set all new objects to be target by default + + + Set all newly added objects to target + + + + + + + + -- GitLab From 59fec4ecc7e103366befbd0d38ca315f7b8912a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 11 Jul 2016 08:38:03 +0200 Subject: [PATCH 3/3] Use option if objects should be target by default --- .../Plugin-TypeBSplineCurve/TypeBSplineCurve.cc | 14 +++++++++++++- .../TypeBSplineSurface.cc | 13 ++++++++++++- .../Plugin-TypeCamera/TypeCamera.cc | 13 ++++++++++++- .../Plugin-TypeCoordsys/TypeCoordsys.cc | 16 ++++++++++++++-- .../TypeHexahedralMesh.cc | 14 +++++++++++++- .../Plugin-TypePlane/TypePlane.cc | 16 +++++++++++++--- .../Plugin-TypePolyLine/TypePolyLine.cc | 16 ++++++++++++++-- .../Plugin-TypePolyMesh/TypePolyMesh.cc | 14 +++++++++++++- .../TypePolyhedralMesh.cc | 14 +++++++++++++- .../Plugin-TypeSkeleton/TypeSkeleton.cc | 14 +++++++++++++- .../Plugin-TypeSphere/TypeSphere.cc | 13 ++++++++++++- .../Plugin-TypeSplatCloud/TypeSplatCloud.cc | 15 ++++++++++++++- .../Plugin-TypeTriangleMesh/TypeTriangleMesh.cc | 14 +++++++++++++- 13 files changed, 169 insertions(+), 17 deletions(-) diff --git a/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc b/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc index f052af64d..b4d8d8306 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeBSplineCurve/TypeBSplineCurve.cc @@ -274,7 +274,19 @@ addEmpty() // new object data struct BSplineCurveObject * object = new BSplineCurveObject(); - object->target(true); + + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = "BSplineCurve_" + QString::number( object->id() ) + ".bsc"; diff --git a/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc b/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc index 816542d4c..a56b97df4 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeBSplineSurface/TypeBSplineSurface.cc @@ -272,7 +272,18 @@ addEmpty() // new object data struct BSplineSurfaceObject * object = new BSplineSurfaceObject(); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = "BSplineSurface_" + QString::number( object->id() ) + ".bss"; diff --git a/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc b/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc index 37e18d6f7..c016464df 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeCamera/TypeCamera.cc @@ -116,7 +116,18 @@ int TypeCameraPlugin::addEmpty() { // new object data struct CameraObject* object = new CameraObject (); - object->target ( true ); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New Camera %1.cam").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc b/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc index ed6c4981c..8314064d9 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeCoordsys/TypeCoordsys.cc @@ -48,7 +48,8 @@ \*===========================================================================*/ #include "TypeCoordsys.hh" -#include "OpenFlipper/BasePlugin/PluginFunctions.hh" +#include +#include TypeCoordsysPlugin::TypeCoordsysPlugin() { @@ -65,7 +66,18 @@ int TypeCoordsysPlugin::addEmpty(){ // new object data struct CoordsysObject * object = new CoordsysObject(); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New Coordinate System %1.cos").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc b/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc index 389f2e461..51daa74f2 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc @@ -49,6 +49,7 @@ #include "TypeHexahedralMesh.hh" #include +#include TypeHexahedralMeshPlugin::TypeHexahedralMeshPlugin() : render_switch_(0), @@ -103,7 +104,18 @@ int TypeHexahedralMeshPlugin::addEmpty() { // New object data struct HexahedralMeshObject* object = new HexahedralMeshObject(DATA_HEXAHEDRAL_MESH); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New Hexahedral Mesh %1.ovm").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc b/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc index 5631e8588..29e43adc7 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePlane/TypePlane.cc @@ -50,8 +50,7 @@ #include "TypePlane.hh" -#include "OpenFlipper/BasePlugin/PluginFunctions.hh" - +#include #include TypePlanePlugin::TypePlanePlugin() { @@ -69,7 +68,18 @@ int TypePlanePlugin::addEmpty(){ // new object data struct PlaneObject * object = new PlaneObject(); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New Plane %1.pla").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc b/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc index d456a549f..109f5f917 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePolyLine/TypePolyLine.cc @@ -50,7 +50,8 @@ #include "TypePolyLine.hh" -#include "OpenFlipper/BasePlugin/PluginFunctions.hh" +#include +#include TypePolyLinePlugin::TypePolyLinePlugin() { @@ -67,7 +68,18 @@ int TypePolyLinePlugin::addEmpty(){ // new object data struct PolyLineObject * object = new PolyLineObject(); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = tr("New PolyLine %1.pol").arg( object->id() ); diff --git a/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc b/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc index 7c5d929f9..4ef1f7170 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePolyMesh/TypePolyMesh.cc @@ -52,6 +52,7 @@ #include #include "PolyMeshBackup.hh" +#include //----------------------------------------------------------------------------- @@ -75,7 +76,18 @@ int TypePolyMeshPlugin::addEmpty(){ // new object data struct PolyMeshObject * object = new PolyMeshObject( typeId("PolyMesh") ); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New PolyMesh %1.off").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc b/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc index 4beab353f..04a2d3205 100644 --- a/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc @@ -49,6 +49,7 @@ #include "TypePolyhedralMesh.hh" #include +#include TypePolyhedralMeshPlugin::TypePolyhedralMeshPlugin() : render_switch_(NULL), @@ -111,7 +112,18 @@ int TypePolyhedralMeshPlugin::addEmpty() { // new object data struct PolyhedralMeshObject* object = new PolyhedralMeshObject(DATA_POLYHEDRAL_MESH); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New PolyHedral Mesh %1.ovm").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc b/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc index b16c312ad..3091e919a 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeSkeleton/TypeSkeleton.cc @@ -52,6 +52,7 @@ #include "OpenFlipper/BasePlugin/PluginFunctions.hh" #include +#include #include "SkeletonBackup.hh" TypeSkeletonPlugin::TypeSkeletonPlugin() @@ -193,7 +194,18 @@ int TypeSkeletonPlugin::addEmpty(){ // new object data struct SkeletonObject * object = new SkeletonObject(); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New Skeleton %1.skl").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc b/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc index e37a91966..a137ad32d 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeSphere/TypeSphere.cc @@ -70,7 +70,18 @@ int TypeSpherePlugin::addEmpty(){ // new object data struct SphereObject * object = new SphereObject(); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New Sphere %1.sph").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc b/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc index b258ce130..ce93f07dd 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeSplatCloud/TypeSplatCloud.cc @@ -60,9 +60,11 @@ #include "TypeSplatCloud.hh" #include +#include #include "SplatCloudBackup.hh" + //== CONSTANTS =================================================== @@ -296,7 +298,18 @@ int TypeSplatCloudPlugin::addEmpty() if( object == 0 ) return -1; - object->target( true ); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("New Splat Cloud %1.spl").arg( object->id() )); diff --git a/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc b/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc index b2a9cde08..8b3eda013 100644 --- a/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc +++ b/PluginCollection-TypePlugins/Plugin-TypeTriangleMesh/TypeTriangleMesh.cc @@ -52,6 +52,7 @@ #include #include "TriMeshBackup.hh" +#include //----------------------------------------------------------------------------- @@ -74,7 +75,18 @@ int TypeTriangleMeshPlugin::addEmpty(){ // new object data struct TriMeshObject * object = new TriMeshObject( typeId("TriangleMesh") ); - object->target(true); + if ( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() ) + object->target(true); + else { + + // Only the first object in the scene will be target + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + // If no target is available, we set the new object as target + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + } QString name = QString(tr("TriangleMesh new %1.off").arg( object->id() )); -- GitLab