fix whitespaces

This commit is contained in:
wmayer 2016-08-25 12:27:08 +02:00
parent c90da8e5fb
commit 46adbae952
4 changed files with 277 additions and 277 deletions

View File

@ -587,48 +587,48 @@ void CmdPartDesignMoveFeature::activated(int iMsg)
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(Part::Feature::getClassTypeId());
if (features.empty()) return;
// Check if all features are valid to move
if (std::any_of(std::begin(features), std::end(features), [](App::DocumentObject* obj){return !PartDesignGui::isFeatureMovable(obj); }))
{
//show messagebox and cancel
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Features cannot be moved"),
QObject::tr("Some of the selected features have dependencies in the source body"));
return;
}
// Check if all features are valid to move
if (std::any_of(std::begin(features), std::end(features), [](App::DocumentObject* obj){return !PartDesignGui::isFeatureMovable(obj); }))
{
//show messagebox and cancel
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Features cannot be moved"),
QObject::tr("Some of the selected features have dependencies in the source body"));
return;
}
// Collect dependenies of the selected features
std::vector<App::DocumentObject*> dependencies = PartDesignGui::collectMovableDependencies(features);
if (!dependencies.empty())
features.insert(std::end(features), std::begin(dependencies), std::end(dependencies));
// Collect dependenies of the selected features
std::vector<App::DocumentObject*> dependencies = PartDesignGui::collectMovableDependencies(features);
if (!dependencies.empty())
features.insert(std::end(features), std::begin(dependencies), std::end(dependencies));
// Create a list of all bodies in this part
std::vector<App::DocumentObject*> bodies = getDocument()->getObjectsOfType(Part::BodyBase::getClassTypeId());
std::set<App::DocumentObject*> source_bodies;
for (auto feat : features) {
PartDesign::Body* source = PartDesign::Body::findBodyOf(feat);
source_bodies.insert(static_cast<App::DocumentObject*>(source));
}
std::vector<App::DocumentObject*> target_bodies;
for (auto body : bodies) {
if (!source_bodies.count(body))
target_bodies.push_back(body);
}
std::set<App::DocumentObject*> source_bodies;
for (auto feat : features) {
PartDesign::Body* source = PartDesign::Body::findBodyOf(feat);
source_bodies.insert(static_cast<App::DocumentObject*>(source));
}
if (target_bodies.empty())
{
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Features cannot be moved"),
QObject::tr("There are no other bodies to move to"));
return;
}
std::vector<App::DocumentObject*> target_bodies;
for (auto body : bodies) {
if (!source_bodies.count(body))
target_bodies.push_back(body);
}
if (target_bodies.empty())
{
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Features cannot be moved"),
QObject::tr("There are no other bodies to move to"));
return;
}
// Ask user to select the target body (remove source bodies from list)
bool ok;
QStringList items;
for (auto body : target_bodies) {
items.push_back(QString::fromUtf8(body->Label.getValue()));
}
for (auto body : target_bodies) {
items.push_back(QString::fromUtf8(body->Label.getValue()));
}
QString text = QInputDialog::getItem(Gui::getMainWindow(),
qApp->translate("PartDesign_MoveFeature", "Select body"),
qApp->translate("PartDesign_MoveFeature", "Select a body from the list"),
@ -637,7 +637,7 @@ void CmdPartDesignMoveFeature::activated(int iMsg)
int index = items.indexOf(text);
if (index < 0) return;
PartDesign::Body* target = static_cast<PartDesign::Body*>(target_bodies[index]);
PartDesign::Body* target = static_cast<PartDesign::Body*>(target_bodies[index]);
openCommand("Move an object");
@ -668,8 +668,8 @@ void CmdPartDesignMoveFeature::activated(int iMsg)
// If we removed the tip of the source body, make the new tip visible
if ( featureWasTip ) {
App::DocumentObject * sourceNewTip = source->Tip.getValue();
if (sourceNewTip)
doCommand(Gui,"Gui.activeDocument().show(\"%s\")", sourceNewTip->getNameInDocument());
if (sourceNewTip)
doCommand(Gui,"Gui.activeDocument().show(\"%s\")", sourceNewTip->getNameInDocument());
}
// Hide old tip and show new tip (the moved feature) of the target body
@ -695,8 +695,8 @@ void CmdPartDesignMoveFeature::activated(int iMsg)
}
}
//relink origin for sketches and datums (coordinates)
PartDesignGui::relinkToOrigin(feat, target);
//relink origin for sketches and datums (coordinates)
PartDesignGui::relinkToOrigin(feat, target);
}
updateActive();

View File

@ -715,7 +715,7 @@ bool TaskDlgPipeParameters::accept()
//the user has to decide which option we should take if external references are used
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(getPipeView()->getObject());
auto pcActiveBody = PartDesignGui::getBodyFor(pcPipe, false);
auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);
//auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);
std::vector<App::DocumentObject*> copies;
bool ext = false;

View File

@ -348,142 +348,142 @@ void relinkToBody (PartDesign::Feature *feature) {
bool isFeatureMovable(App::DocumentObject* const feat)
{
if (feat->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
auto prim = static_cast<PartDesign::Feature*>(feat);
App::DocumentObject* bf = prim->BaseFeature.getValue();
if (bf)
return false;
}
if (feat->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
auto prim = static_cast<PartDesign::Feature*>(feat);
App::DocumentObject* bf = prim->BaseFeature.getValue();
if (bf)
return false;
}
if (feat->getTypeId().isDerivedFrom(PartDesign::FeaturePrimitive::getClassTypeId())) {
auto prim = static_cast<PartDesign::FeaturePrimitive*>(feat);
if (feat->getTypeId().isDerivedFrom(PartDesign::FeaturePrimitive::getClassTypeId())) {
auto prim = static_cast<PartDesign::FeaturePrimitive*>(feat);
if (!isFeatureMovable(prim->CoordinateSystem.getValue()))
return false;
}
if (!isFeatureMovable(prim->CoordinateSystem.getValue()))
return false;
}
if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) {
auto prim = static_cast<PartDesign::ProfileBased*>(feat);
auto sk = prim->getVerifiedSketch(true);
if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) {
auto prim = static_cast<PartDesign::ProfileBased*>(feat);
auto sk = prim->getVerifiedSketch(true);
if (!isFeatureMovable(static_cast<App::DocumentObject*>(sk)))
return false;
if (auto prop = static_cast<App::PropertyLinkList*>(prim->getPropertyByName("Sections"))) {
if (std::any_of(prop->getValues().begin(), prop->getValues().end(), [](App::DocumentObject* obj){return !isFeatureMovable(obj); }))
return false;
}
if (!isFeatureMovable(static_cast<App::DocumentObject*>(sk)))
return false;
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("ReferenceAxis"))) {
App::DocumentObject* axis = prop->getValue();
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
return false;
}
if (auto prop = static_cast<App::PropertyLinkList*>(prim->getPropertyByName("Sections"))) {
if (std::any_of(prop->getValues().begin(), prop->getValues().end(), [](App::DocumentObject* obj){return !isFeatureMovable(obj); }))
return false;
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("Spine"))) {
App::DocumentObject* axis = prop->getValue();
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
return false;
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("ReferenceAxis"))) {
App::DocumentObject* axis = prop->getValue();
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
return false;
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("AuxillerySpine"))) {
App::DocumentObject* axis = prop->getValue();
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
return false;
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("Spine"))) {
App::DocumentObject* axis = prop->getValue();
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
return false;
}
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("AuxillerySpine"))) {
App::DocumentObject* axis = prop->getValue();
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
return false;
}
if (feat->getTypeId().isDerivedFrom(Part::AttachableObject::getClassTypeId())) {
auto attachable = static_cast<Part::AttachableObject*>(feat);
App::DocumentObject* support = attachable->Support.getValue();
if (support && !support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()))
return false;
}
}
return true;
if (feat->getTypeId().isDerivedFrom(Part::AttachableObject::getClassTypeId())) {
auto attachable = static_cast<Part::AttachableObject*>(feat);
App::DocumentObject* support = attachable->Support.getValue();
if (support && !support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()))
return false;
}
return true;
}
std::vector<App::DocumentObject*> collectMovableDependencies(std::vector<App::DocumentObject*>& features)
{
std::set<App::DocumentObject*> unique_objs;
std::set<App::DocumentObject*> unique_objs;
for (auto const &feat : features)
{
// Get coordinate system object
if (feat->getTypeId().isDerivedFrom(PartDesign::FeaturePrimitive::getClassTypeId())) {
auto prim = static_cast<PartDesign::FeaturePrimitive*>(feat);
App::DocumentObject* cs = prim->CoordinateSystem.getValue();
if (cs && cs->getTypeId() == PartDesign::CoordinateSystem::getClassTypeId())
unique_objs.insert(cs);
}
for (auto const &feat : features)
{
// Get coordinate system object
if (feat->getTypeId().isDerivedFrom(PartDesign::FeaturePrimitive::getClassTypeId())) {
auto prim = static_cast<PartDesign::FeaturePrimitive*>(feat);
App::DocumentObject* cs = prim->CoordinateSystem.getValue();
if (cs && cs->getTypeId() == PartDesign::CoordinateSystem::getClassTypeId())
unique_objs.insert(cs);
}
// Get sketches and datums from profile based features
if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) {
auto prim = static_cast<PartDesign::ProfileBased*>(feat);
Part::Part2DObject* sk = prim->getVerifiedSketch(true);
if (sk) {
unique_objs.insert(static_cast<App::DocumentObject*>(sk));
}
if (auto prop = static_cast<App::PropertyLinkList*>(prim->getPropertyByName("Sections"))) {
for (App::DocumentObject* obj : prop->getValues()) {
unique_objs.insert(obj);
}
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("ReferenceAxis"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
unique_objs.insert(axis);
}
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("Spine"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
unique_objs.insert(axis);
}
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("AuxillerySpine"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
unique_objs.insert(axis);
}
}
}
}
// Get sketches and datums from profile based features
if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) {
auto prim = static_cast<PartDesign::ProfileBased*>(feat);
Part::Part2DObject* sk = prim->getVerifiedSketch(true);
if (sk) {
unique_objs.insert(static_cast<App::DocumentObject*>(sk));
}
if (auto prop = static_cast<App::PropertyLinkList*>(prim->getPropertyByName("Sections"))) {
for (App::DocumentObject* obj : prop->getValues()) {
unique_objs.insert(obj);
}
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("ReferenceAxis"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
unique_objs.insert(axis);
}
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("Spine"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
unique_objs.insert(axis);
}
}
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("AuxillerySpine"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
unique_objs.insert(axis);
}
}
}
}
std::vector<App::DocumentObject*> result;
result.reserve(unique_objs.size());
result.insert(result.begin(), unique_objs.begin(), unique_objs.end());
std::vector<App::DocumentObject*> result;
result.reserve(unique_objs.size());
result.insert(result.begin(), unique_objs.begin(), unique_objs.end());
return result;
return result;
}
void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody)
{
if (feat->getTypeId().isDerivedFrom(Part::AttachableObject::getClassTypeId())) {
auto attachable = static_cast<Part::AttachableObject*>(feat);
App::DocumentObject* support = attachable->Support.getValue();
if (support && support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) {
auto originfeat = static_cast<App::OriginFeature*>(support);
App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue());
if (targetOriginFeature) {
attachable->Support.setValue(static_cast<App::DocumentObject*>(targetOriginFeature), "");
}
}
}
else if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) {
auto prim = static_cast<PartDesign::ProfileBased*>(feat);
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("ReferenceAxis"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
auto originfeat = static_cast<App::OriginFeature*>(axis);
App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue());
if (targetOriginFeature) {
prop->setValue(static_cast<App::DocumentObject*>(targetOriginFeature), std::vector<std::string>(0));
}
}
}
}
if (feat->getTypeId().isDerivedFrom(Part::AttachableObject::getClassTypeId())) {
auto attachable = static_cast<Part::AttachableObject*>(feat);
App::DocumentObject* support = attachable->Support.getValue();
if (support && support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) {
auto originfeat = static_cast<App::OriginFeature*>(support);
App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue());
if (targetOriginFeature) {
attachable->Support.setValue(static_cast<App::DocumentObject*>(targetOriginFeature), "");
}
}
}
else if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) {
auto prim = static_cast<PartDesign::ProfileBased*>(feat);
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("ReferenceAxis"))) {
App::DocumentObject* axis = prop->getValue();
if (axis && axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){
auto originfeat = static_cast<App::OriginFeature*>(axis);
App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue());
if (targetOriginFeature) {
prop->setValue(static_cast<App::DocumentObject*>(targetOriginFeature), std::vector<std::string>(0));
}
}
}
}
}
} /* PartDesignGui */
} /* PartDesignGui */

View File

@ -34,26 +34,26 @@ from PySide.QtGui import QApplication
#timer runs this class in order to access modal dialog
class CallableCheckWarning:
def __init__(self, test):
self.test = test
def __call__(self):
diag = QApplication.activeModalWidget()
self.test.assertIsNotNone(diag, "Input dialog box could not be found")
if (diag != None):
QtCore.QTimer.singleShot(0, diag, QtCore.SLOT('accept()'))
def __init__(self, test):
self.test = test
def __call__(self):
diag = QApplication.activeModalWidget()
self.test.assertIsNotNone(diag, "Input dialog box could not be found")
if (diag != None):
QtCore.QTimer.singleShot(0, diag, QtCore.SLOT('accept()'))
class CallableComboBox:
def __init__(self, test):
self.test = test
def __call__(self):
diag = QApplication.activeModalWidget()
self.test.assertIsNotNone(diag, "Warning dialog box could not be found")
if (diag != None):
cbox = diag.findChild(QtGui.QComboBox)
self.test.assertIsNotNone(cbox, "ComboBox widget could not be found")
if (cbox != None):
cbox.setCurrentIndex(1)
QtCore.QTimer.singleShot(0, diag, QtCore.SLOT('accept()'))
def __init__(self, test):
self.test = test
def __call__(self):
diag = QApplication.activeModalWidget()
self.test.assertIsNotNone(diag, "Warning dialog box could not be found")
if (diag != None):
cbox = diag.findChild(QtGui.QComboBox)
self.test.assertIsNotNone(cbox, "ComboBox widget could not be found")
if (cbox != None):
cbox.setCurrentIndex(1)
QtCore.QTimer.singleShot(0, diag, QtCore.SLOT('accept()'))
App = FreeCAD
Gui = FreeCADGui
@ -61,129 +61,129 @@ Gui = FreeCADGui
# define the test cases to test the FreeCAD PartDesign module
#---------------------------------------------------------------------------
class PartDesignGuiTestCases(unittest.TestCase):
def setUp(self):
self.Doc = FreeCAD.newDocument("SketchGuiTest")
def setUp(self):
self.Doc = FreeCAD.newDocument("SketchGuiTest")
def testRefuseToMoveSingleFeature(self):
FreeCAD.Console.PrintMessage('Testing moving one feature from one body to another\n')
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
Gui.activeView().setActiveObject('pdbody', self.BodySource)
def testRefuseToMoveSingleFeature(self):
FreeCAD.Console.PrintMessage('Testing moving one feature from one body to another\n')
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
Gui.activeView().setActiveObject('pdbody', self.BodySource)
self.BoxObj = self.Doc.addObject('PartDesign::AdditiveBox','Box')
self.BoxObj.Length=10.0
self.BoxObj.Width=10.0
self.BoxObj.Height=10.0
self.BodySource.addFeature(self.BoxObj)
self.BoxObj = self.Doc.addObject('PartDesign::AdditiveBox','Box')
self.BoxObj.Length=10.0
self.BoxObj.Width=10.0
self.BoxObj.Height=10.0
self.BodySource.addFeature(self.BoxObj)
self.BoxCoords = self.Doc.addObject('PartDesign::CoordinateSystem','CoordinateSystem')
self.BodySource.addFeature(self.BoxCoords)
self.BoxObj.CoordinateSystem=(self.BoxCoords)
App.ActiveDocument.recompute()
Gui.activeDocument().hide('CoordinateSystem')
self.BoxCoords = self.Doc.addObject('PartDesign::CoordinateSystem','CoordinateSystem')
self.BodySource.addFeature(self.BoxCoords)
self.BoxObj.CoordinateSystem=(self.BoxCoords)
App.ActiveDocument.recompute()
Gui.activeDocument().hide('CoordinateSystem')
self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
self.Sketch.Support = (self.BoxObj, ('Face3',))
self.Sketch.MapMode = 'FlatFace'
self.BodySource.addFeature(self.Sketch)
self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
self.Sketch.Support = (self.BoxObj, ('Face3',))
self.Sketch.MapMode = 'FlatFace'
self.BodySource.addFeature(self.Sketch)
geoList = []
geoList.append(Part.Line(App.Vector(2.0,8.0,0),App.Vector(8.0,8.0,0)))
geoList.append(Part.Line(App.Vector(8.0,8.0,0),App.Vector(8.0,2.0,0)))
geoList.append(Part.Line(App.Vector(8.0,2.0,0),App.Vector(2.0,2.0,0)))
geoList.append(Part.Line(App.Vector(2.0,2.0,0),App.Vector(2.0,8.0,0)))
self.Sketch.addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
conList.append(Sketcher.Constraint('Horizontal',0))
conList.append(Sketcher.Constraint('Horizontal',2))
conList.append(Sketcher.Constraint('Vertical',1))
conList.append(Sketcher.Constraint('Vertical',3))
self.Sketch.addConstraint(conList)
geoList = []
geoList.append(Part.Line(App.Vector(2.0,8.0,0),App.Vector(8.0,8.0,0)))
geoList.append(Part.Line(App.Vector(8.0,8.0,0),App.Vector(8.0,2.0,0)))
geoList.append(Part.Line(App.Vector(8.0,2.0,0),App.Vector(2.0,2.0,0)))
geoList.append(Part.Line(App.Vector(2.0,2.0,0),App.Vector(2.0,8.0,0)))
self.Sketch.addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
conList.append(Sketcher.Constraint('Horizontal',0))
conList.append(Sketcher.Constraint('Horizontal',2))
conList.append(Sketcher.Constraint('Vertical',1))
conList.append(Sketcher.Constraint('Vertical',3))
self.Sketch.addConstraint(conList)
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
self.Pad.Profile = self.Sketch
self.Pad.Length = 10.000000
self.Pad.Length2 = 100.000000
self.Pad.Type = 0
self.Pad.UpToFace = None
self.Pad.Reversed = 0
self.Pad.Midplane = 0
self.Pad.Offset = 0.000000
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
self.Pad.Profile = self.Sketch
self.Pad.Length = 10.000000
self.Pad.Length2 = 100.000000
self.Pad.Type = 0
self.Pad.UpToFace = None
self.Pad.Reversed = 0
self.Pad.Midplane = 0
self.Pad.Offset = 0.000000
self.BodySource.addFeature(self.Pad)
self.BodySource.addFeature(self.Pad)
self.Doc.recompute()
Gui.SendMsgToActiveView("ViewFit")
self.Doc.recompute()
Gui.SendMsgToActiveView("ViewFit")
self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
Gui.Selection.addSelection(App.ActiveDocument.Pad)
cobj = CallableCheckWarning(self)
QtCore.QTimer.singleShot(500, cobj)
Gui.runCommand('PartDesign_MoveFeature')
#assert depenedencies of the Sketch
self.assertEqual(len(self.BodySource.Model), 4, "Source body feature count is wrong")
self.assertEqual(len(self.BodyTarget.Model), 0, "Target body feature count is wrong")
self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
def testMoveSingleFeature(self):
FreeCAD.Console.PrintMessage('Testing moving one feature from one body to another\n')
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
Gui.activeView().setActiveObject('pdbody', self.BodySource)
Gui.Selection.addSelection(App.ActiveDocument.Pad)
cobj = CallableCheckWarning(self)
QtCore.QTimer.singleShot(500, cobj)
Gui.runCommand('PartDesign_MoveFeature')
#assert depenedencies of the Sketch
self.assertEqual(len(self.BodySource.Model), 4, "Source body feature count is wrong")
self.assertEqual(len(self.BodyTarget.Model), 0, "Target body feature count is wrong")
self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
self.Sketch.Support = (self.Doc.XY_Plane, [''])
self.Sketch.MapMode = 'FlatFace'
self.BodySource.addFeature(self.Sketch)
def testMoveSingleFeature(self):
FreeCAD.Console.PrintMessage('Testing moving one feature from one body to another\n')
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
Gui.activeView().setActiveObject('pdbody', self.BodySource)
geoList = []
geoList.append(Part.Line(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0)))
geoList.append(Part.Line(App.Vector(10.000000,10.000000,0),App.Vector(10.000000,-10.000000,0)))
geoList.append(Part.Line(App.Vector(10.000000,-10.000000,0),App.Vector(-10.000000,-10.000000,0)))
geoList.append(Part.Line(App.Vector(-10.000000,-10.000000,0),App.Vector(-10.000000,10.000000,0)))
self.Sketch.addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
conList.append(Sketcher.Constraint('Horizontal',0))
conList.append(Sketcher.Constraint('Horizontal',2))
conList.append(Sketcher.Constraint('Vertical',1))
conList.append(Sketcher.Constraint('Vertical',3))
self.Sketch.addConstraint(conList)
self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
self.Sketch.Support = (self.Doc.XY_Plane, [''])
self.Sketch.MapMode = 'FlatFace'
self.BodySource.addFeature(self.Sketch)
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
self.Pad.Profile = self.Sketch
self.Pad.Length = 10.000000
self.Pad.Length2 = 100.000000
self.Pad.Type = 0
self.Pad.UpToFace = None
self.Pad.Reversed = 0
self.Pad.Midplane = 0
self.Pad.Offset = 0.000000
geoList = []
geoList.append(Part.Line(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0)))
geoList.append(Part.Line(App.Vector(10.000000,10.000000,0),App.Vector(10.000000,-10.000000,0)))
geoList.append(Part.Line(App.Vector(10.000000,-10.000000,0),App.Vector(-10.000000,-10.000000,0)))
geoList.append(Part.Line(App.Vector(-10.000000,-10.000000,0),App.Vector(-10.000000,10.000000,0)))
self.Sketch.addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
conList.append(Sketcher.Constraint('Horizontal',0))
conList.append(Sketcher.Constraint('Horizontal',2))
conList.append(Sketcher.Constraint('Vertical',1))
conList.append(Sketcher.Constraint('Vertical',3))
self.Sketch.addConstraint(conList)
self.BodySource.addFeature(self.Pad)
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
self.Pad.Profile = self.Sketch
self.Pad.Length = 10.000000
self.Pad.Length2 = 100.000000
self.Pad.Type = 0
self.Pad.UpToFace = None
self.Pad.Reversed = 0
self.Pad.Midplane = 0
self.Pad.Offset = 0.000000
self.Doc.recompute()
Gui.SendMsgToActiveView("ViewFit")
self.BodySource.addFeature(self.Pad)
self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
Gui.Selection.addSelection(App.ActiveDocument.Pad)
cobj = CallableComboBox(self)
QtCore.QTimer.singleShot(500, cobj)
Gui.runCommand('PartDesign_MoveFeature')
#assert depenedencies of the Sketch
self.assertFalse(self.Sketch.Support[0][0] in self.BodySource.Origin.OriginFeatures)
self.assertTrue(self.Sketch.Support[0][0] in self.BodyTarget.Origin.OriginFeatures)
self.assertEqual(len(self.BodySource.Model), 0, "Source body feature count is wrong")
self.assertEqual(len(self.BodyTarget.Model), 2, "Target body feature count is wrong")
self.Doc.recompute()
Gui.SendMsgToActiveView("ViewFit")
def tearDown(self):
FreeCAD.closeDocument("SketchGuiTest")
self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
Gui.Selection.addSelection(App.ActiveDocument.Pad)
cobj = CallableComboBox(self)
QtCore.QTimer.singleShot(500, cobj)
Gui.runCommand('PartDesign_MoveFeature')
#assert depenedencies of the Sketch
self.assertFalse(self.Sketch.Support[0][0] in self.BodySource.Origin.OriginFeatures)
self.assertTrue(self.Sketch.Support[0][0] in self.BodyTarget.Origin.OriginFeatures)
self.assertEqual(len(self.BodySource.Model), 0, "Source body feature count is wrong")
self.assertEqual(len(self.BodyTarget.Model), 2, "Target body feature count is wrong")
def tearDown(self):
FreeCAD.closeDocument("SketchGuiTest")
#class PartDesignGuiTestCases(unittest.TestCase):
# def setUp(self):