From 480095785812e21a55daf21da5686ffe614d2f54 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Thu, 2 Jul 2015 15:26:16 +0300 Subject: [PATCH] Attacher: change Part2DObject's MapMode default to mmDeactivated, and set mode to mmFlatFace only when reading files of old format. PartDesign, Sketcher: set mapping mode when setting support Mapping mode mmFlatFace is no longer default, so an explicit assignment is required. --- src/Mod/Part/App/AttachableObject.cpp | 3 +-- src/Mod/Part/App/Part2DObject.cpp | 2 ++ src/Mod/PartDesign/Gui/Command.cpp | 2 ++ src/Mod/PartDesign/Gui/Workbench.cpp | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/AttachableObject.cpp b/src/Mod/Part/App/AttachableObject.cpp index 2bec3775d..a2ec2d8d9 100644 --- a/src/Mod/Part/App/AttachableObject.cpp +++ b/src/Mod/Part/App/AttachableObject.cpp @@ -41,8 +41,7 @@ AttachableObject::AttachableObject() { ADD_PROPERTY_TYPE(Support, (0,0), "Attachment",(App::PropertyType)(App::Prop_None),"Support of the 2D geometry"); - //It is necessary to default to mmToFlatFace, in order to load old files - ADD_PROPERTY_TYPE(MapMode, (mmFlatFace), "Attachment", App::Prop_None, "Mode of attachment to other object"); + ADD_PROPERTY_TYPE(MapMode, (mmDeactivated), "Attachment", App::Prop_None, "Mode of attachment to other object"); MapMode.setEnums(AttachEngine::eMapModeStrings); ADD_PROPERTY_TYPE(MapReversed, (false), "Attachment", App::Prop_None, "Reverse Z direction (flip sketch upside down)"); diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index 22cd97ef8..ae471fd9e 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -233,10 +233,12 @@ void Part2DObject::Restore(Base::XMLReader &reader) if (strcmp(prop->getTypeId().getName(), TypeName) == 0){ prop->Restore(reader); } else if (prop->isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())){ + //reading legacy Support - when the Support could only be a single flat face. App::PropertyLinkSub tmp;//getTypeId() is not static =( if (0 == strcmp(tmp.getTypeId().getName(),TypeName)) { static_cast(prop)->Restore_FromLinkSub(reader); } + this->MapMode.setValue(Attacher::mmFlatFace); } } } diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index f7f58a76b..aaebd46d0 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -815,6 +815,7 @@ void CmdPartDesignNewSketch::activated(int iMsg) openCommand("Create a Sketch on Face"); doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Support = %s",FeatName.c_str(),supportString.c_str()); + doCommand(Doc,"App.activeDocument().%s.MapMode = '%s'",FeatName.c_str(),Attacher::AttachEngine::eMapModeStrings[Attacher::mmFlatFace]); doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); doCommand(Gui,"App.activeDocument().recompute()"); // recompute the sketch placement based on its support @@ -890,6 +891,7 @@ void CmdPartDesignNewSketch::activated(int iMsg) Gui::Command::openCommand("Create a new Sketch"); Gui::Command::doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str()); Gui::Command::doCommand(Doc,"App.activeDocument().%s.Support = %s",FeatName.c_str(),supportString.c_str()); + Gui::Command::doCommand(Doc,"App.activeDocument().%s.MapMode = '%s'",FeatName.c_str(),Attacher::AttachEngine::eMapModeStrings[Attacher::mmFlatFace]); Gui::Command::updateActive(); // Make sure the Support's Placement property is updated Gui::Command::doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 2f621e385..bf0608c84 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -373,6 +373,9 @@ void Workbench::fixSketchSupport (Sketcher::SketchObject* sketch) // One of the base planes Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = (App.activeDocument().%s,['%s'])", sketch->getNameInDocument(), App::Part::BaseplaneTypes[index], side.c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.MapMode = '%s'", + sketch->getNameInDocument(), Attacher::AttachEngine::eMapModeStrings[Attacher::mmFlatFace]); + } else { // Offset to base plane // Find out which direction we need to offset @@ -392,6 +395,8 @@ void Workbench::fixSketchSupport (Sketcher::SketchObject* sketch) body->getNameInDocument(), Datum.c_str(), sketch->getNameInDocument()); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = (App.activeDocument().%s,['%s'])", sketch->getNameInDocument(), Datum.c_str(), side.c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.MapMode = '%s'", + sketch->getNameInDocument(),Attacher::AttachEngine::eMapModeStrings[Attacher::mmFlatFace]); Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()"); // recompute the feature based on its references } }