diff --git a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp index b5a95532a9186df3d994a2c15783f7a1ad53e602..5581eaed7e62d6b8676cddf9975477c8da6f6ddc 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp @@ -80,145 +80,8 @@ std::unique_ptr<RealSpace::Layer> TransformTo3D::createLayer( return result; } - std::unique_ptr<RealSpace::Particles::Particle> -TransformTo3D::createParticle(const SessionItem& particleItem) -{ - Q_ASSERT(particleItem.modelType() == Constants::ParticleType); - - std::unique_ptr<RealSpace::Particles::Particle> result; - - auto ffItem = static_cast<FormFactorItem*>( - particleItem.getGroupItem(ParticleItem::P_FORM_FACTOR)); - - if(ffItem->modelType() == Constants::AnisoPyramidType) { - double length = ffItem->getItemValue(AnisoPyramidItem::P_LENGTH).toDouble(); - double width = ffItem->getItemValue(AnisoPyramidItem::P_WIDTH).toDouble(); - double height = ffItem->getItemValue(AnisoPyramidItem::P_HEIGHT).toDouble(); - double alpha = ffItem->getItemValue(AnisoPyramidItem::P_ALPHA).toDouble(); - result = std::make_unique<RealSpace::Particles::AnisoPyramid>(length, width, height, - Units::deg2rad(alpha)); - } - else if(ffItem->modelType() == Constants::BoxType) { - double length = ffItem->getItemValue(BoxItem::P_LENGTH).toDouble(); - double width = ffItem->getItemValue(BoxItem::P_WIDTH).toDouble(); - double height = ffItem->getItemValue(BoxItem::P_HEIGHT).toDouble(); - result = std::make_unique<RealSpace::Particles::Box>(length, width, height); - } - else if(ffItem->modelType() == Constants::ConeType) { - double radius = ffItem->getItemValue(ConeItem::P_RADIUS).toDouble(); - double height = ffItem->getItemValue(ConeItem::P_HEIGHT).toDouble(); - double alpha = ffItem->getItemValue(ConeItem::P_ALPHA).toDouble(); - result = std::make_unique<RealSpace::Particles::Cone>(radius, height, - Units::deg2rad(alpha)); - } - else if(ffItem->modelType() == Constants::Cone6Type) { - double baseedge = ffItem->getItemValue(Cone6Item::P_BASEEDGE).toDouble(); - double height = ffItem->getItemValue(Cone6Item::P_HEIGHT).toDouble(); - double alpha = ffItem->getItemValue(Cone6Item::P_ALPHA).toDouble(); - result = std::make_unique<RealSpace::Particles::Cone6>(baseedge, height, - Units::deg2rad(alpha)); - } - else if(ffItem->modelType() == Constants::CuboctahedronType) { - double length = ffItem->getItemValue(CuboctahedronItem::P_LENGTH).toDouble(); - double height = ffItem->getItemValue(CuboctahedronItem::P_HEIGHT).toDouble(); - double height_ratio = ffItem->getItemValue(CuboctahedronItem::P_HEIGHT_RATIO).toDouble(); - double alpha = ffItem->getItemValue(CuboctahedronItem::P_ALPHA).toDouble(); - result = std::make_unique<RealSpace::Particles::Cuboctahedron>(length, height, - height_ratio, - Units::deg2rad(alpha)); - } - else if(ffItem->modelType() == Constants::CylinderType) { - double radius = ffItem->getItemValue(CylinderItem::P_RADIUS).toDouble(); - double height = ffItem->getItemValue(CylinderItem::P_HEIGHT).toDouble(); - result = std::make_unique<RealSpace::Particles::Cylinder>(radius, height); - } - else if(ffItem->modelType() == Constants::DodecahedronType) { - double edge = ffItem->getItemValue(DodecahedronItem::P_EDGE).toDouble(); - result = std::make_unique<RealSpace::Particles::Dodecahedron>(edge); - } - else if(ffItem->modelType() == Constants::EllipsoidalCylinderType) { - double radius_x = ffItem->getItemValue(EllipsoidalCylinderItem::P_RADIUS_X).toDouble(); - double radius_y = ffItem->getItemValue(EllipsoidalCylinderItem::P_RADIUS_Y).toDouble(); - double height = ffItem->getItemValue(EllipsoidalCylinderItem::P_HEIGHT).toDouble(); - result = std::make_unique<RealSpace::Particles::EllipsoidalCylinder>(radius_x, radius_y, - height); - } - else if(ffItem->modelType() == Constants::FullSphereType) { - double radius = ffItem->getItemValue(FullSphereItem::P_RADIUS).toDouble(); - result = std::make_unique<RealSpace::Particles::FullSphere>(radius); - } - - else if(ffItem->modelType() == Constants::FullSpheroidType) { - double radius = ffItem->getItemValue(FullSpheroidItem::P_RADIUS).toDouble(); - double height = ffItem->getItemValue(FullSpheroidItem::P_HEIGHT).toDouble(); - result = std::make_unique<RealSpace::Particles::FullSpheroid>(radius, height); - } - else if(ffItem->modelType() == Constants::HemiEllipsoidType) { - double radius_x = ffItem->getItemValue(HemiEllipsoidItem::P_RADIUS_X).toDouble(); - double radius_y = ffItem->getItemValue(HemiEllipsoidItem::P_RADIUS_Y).toDouble(); - double height = ffItem->getItemValue(HemiEllipsoidItem::P_HEIGHT).toDouble(); - result = std::make_unique<RealSpace::Particles::HemiEllipsoid>(radius_x, radius_y, - height); - } - else if(ffItem->modelType() == Constants::IcosahedronType) { - double edge = ffItem->getItemValue(IcosahedronItem::P_EDGE).toDouble(); - result = std::make_unique<RealSpace::Particles::Icosahedron>(edge); - } - - else if(ffItem->modelType() == Constants::Prism3Type) { - double baseedge = ffItem->getItemValue(Prism3Item::P_BASEEDGE).toDouble(); - double height = ffItem->getItemValue(Prism3Item::P_HEIGHT).toDouble(); - result = std::make_unique<RealSpace::Particles::Prism3>(baseedge, height); - } - else if(ffItem->modelType() == Constants::Prism6Type) { - double baseedge = ffItem->getItemValue(Prism6Item::P_BASEEDGE).toDouble(); - double height = ffItem->getItemValue(Prism6Item::P_HEIGHT).toDouble(); - result = std::make_unique<RealSpace::Particles::Prism6>(baseedge, height); - } - else if(ffItem->modelType() == Constants::PyramidType) { - double baseedge = ffItem->getItemValue(PyramidItem::P_BASEEDGE).toDouble(); - double height = ffItem->getItemValue(PyramidItem::P_HEIGHT).toDouble(); - double alpha = ffItem->getItemValue(PyramidItem::P_ALPHA).toDouble(); - result = std::make_unique<RealSpace::Particles::Pyramid>(baseedge, height, - Units::deg2rad(alpha)); - } - else if(ffItem->modelType() == Constants::TetrahedronType) { - double baseedge = ffItem->getItemValue(TetrahedronItem::P_BASEEDGE).toDouble(); - double height = ffItem->getItemValue(TetrahedronItem::P_HEIGHT).toDouble(); - double alpha = ffItem->getItemValue(TetrahedronItem::P_ALPHA).toDouble(); - result = std::make_unique<RealSpace::Particles::Tetrahedron>(baseedge, height, - Units::deg2rad(alpha)); - } - else if(ffItem->modelType() == Constants::TruncatedCubeType) { - double length = ffItem->getItemValue(TruncatedCubeItem::P_LENGTH).toDouble(); - double removed_length = ffItem->getItemValue(TruncatedCubeItem::P_REMOVED_LENGTH).toDouble(); - result = std::make_unique<RealSpace::Particles::TruncatedCube>(length, removed_length); - } - else if(ffItem->modelType() == Constants::TruncatedSphereType) { - double radius = ffItem->getItemValue(TruncatedSphereItem::P_RADIUS).toDouble(); - double height = ffItem->getItemValue(TruncatedSphereItem::P_HEIGHT).toDouble(); - //double removed_top = ffItem->getItemValue(TruncatedSphereItem::P_REMOVED_TOP).toDouble(); - result = std::make_unique<RealSpace::Particles::TruncatedSphere>(radius, height); - } - else if(ffItem->modelType() == Constants::TruncatedSpheroidType) { - double radius = ffItem->getItemValue(TruncatedSpheroidItem::P_RADIUS).toDouble(); - double height = ffItem->getItemValue(TruncatedSpheroidItem::P_HEIGHT).toDouble(); - double hfc = ffItem->getItemValue(TruncatedSpheroidItem::P_HFC).toDouble(); - //double removed_top = ffItem->getItemValue(TruncatedSpheroidItem::P_REMOVED_TOP).toDouble(); - result = std::make_unique<RealSpace::Particles::TruncatedSpheroid>(radius, height, hfc); - } - if(result) { - ExternalProperty material - = particleItem.getItemValue(ParticleItem::P_MATERIAL).value<ExternalProperty>(); - - result->color = material.color(); - } - return result; -} - -std::unique_ptr<RealSpace::Particles::Particle> -TransformTo3D::createParticleVersion2(const SessionItem &particleItem) +TransformTo3D::createParticle3D(const SessionItem &particleItem) { Q_ASSERT(particleItem.modelType() == Constants::ParticleType); @@ -231,13 +94,6 @@ TransformTo3D::createParticleVersion2(const SessionItem &particleItem) result = createParticlefromIFormFactor(unique_ff.get()); - // setting colour of the particle - if(result) { - ExternalProperty material - = particleItem.getItemValue(ParticleItem::P_MATERIAL).value<ExternalProperty>(); - - result->color = material.color(); - } return result; } diff --git a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h index 152376aa138aa48b508c8be89eb4a5954feed168..379dd968894445c99faa3d8761934da479b9e2a5 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h +++ b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h @@ -39,11 +39,7 @@ std::unique_ptr<RealSpace::Layer> createLayer(const SessionItem& layerItem, const QVector3D& origin = QVector3D()); BA_CORE_API_ -std::unique_ptr<RealSpace::Particles::Particle> createParticle(const SessionItem& particleItem); - -BA_CORE_API_ -std::unique_ptr<RealSpace::Particles::Particle> createParticleVersion2(const SessionItem& - particleItem); +std::unique_ptr<RealSpace::Particles::Particle> createParticle3D(const SessionItem& particleItem); BA_CORE_API_ std::unique_ptr<RealSpace::Particles::Particle> createParticlefromIFormFactor(const IFormFactor *ff);