Part: Add AttacherEngine of type PropertyEnumeration
This is added to conveniently change the attacher type of a Part object. Hint: A new property is used to avoid to break project files when opening it with an older version. See also forum thread: https://forum.freecad.org/viewtopic.php?t=87891
This commit is contained in:
@@ -54,3 +54,45 @@ TEST_F(AttachExtensionTest, testPlanePlane)
|
||||
getDocument()->recompute();
|
||||
EXPECT_TRUE(true);
|
||||
}
|
||||
|
||||
TEST_F(AttachExtensionTest, testAttacherEngineType)
|
||||
{
|
||||
auto plane = dynamic_cast<Part::Plane*>(getDocument()->addObject("Part::Plane", "Plane"));
|
||||
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEngine3D");
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine 3D");
|
||||
|
||||
plane->AttacherEngine.setValue(1L);
|
||||
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEnginePlane");
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Plane");
|
||||
|
||||
plane->AttacherEngine.setValue(2L);
|
||||
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEngineLine");
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Line");
|
||||
|
||||
plane->AttacherEngine.setValue(3L);
|
||||
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEnginePoint");
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Point");
|
||||
}
|
||||
|
||||
TEST_F(AttachExtensionTest, testAttacherTypeEngine)
|
||||
{
|
||||
auto plane = dynamic_cast<Part::Plane*>(getDocument()->addObject("Part::Plane", "Plane"));
|
||||
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEngine3D");
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine 3D");
|
||||
|
||||
plane->AttacherType.setValue("Attacher::AttachEnginePlane");
|
||||
plane->onExtendedDocumentRestored();
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Plane");
|
||||
|
||||
plane->AttacherType.setValue("Attacher::AttachEngineLine");
|
||||
plane->onExtendedDocumentRestored();
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Line");
|
||||
|
||||
plane->AttacherType.setValue("Attacher::AttachEnginePoint");
|
||||
plane->onExtendedDocumentRestored();
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Point");
|
||||
|
||||
plane->AttacherType.setValue("Attacher::AttachEngine3D");
|
||||
plane->onExtendedDocumentRestored();
|
||||
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine 3D");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user