diff --git a/src/Mod/Assembly/App/AppAssemblyPy.cpp b/src/Mod/Assembly/App/AppAssemblyPy.cpp index 22473a319..f9d0573bb 100644 --- a/src/Mod/Assembly/App/AppAssemblyPy.cpp +++ b/src/Mod/Assembly/App/AppAssemblyPy.cpp @@ -46,7 +46,7 @@ App::Document *ActiveAppDoc =0; Gui::ViewProviderDocumentObject *ActiveVp =0; // The names of the base planes. Note: The user-visible label is different from this -const char* BaseplaneNames[3] = {"BaseplaneXY", "BaseplaneYZ", "BaseplaneXZ"}; +const char* BaseplaneNames[3] = {"BaseplaneXY", "BaseplaneXZ", "BaseplaneYZ"}; } diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index e6122d69f..b170d05d5 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -90,10 +90,8 @@ void Part2DObject::positionBySupport(void) Base::Vector3d dir; Place.getRotation().multVec(Base::Vector3d(0,0,1),dir); const std::vector &sub = Support.getSubValues(); - if (!sub.empty() && (sub[0] == "back")) { + if (!sub.empty() && (sub[0] == "back")) Reverse = true; - dir *= -1.0; - } // Set placement identical to the way it used to be done in the Sketcher::SketchOrientationDialog if (dir == Base::Vector3d(0,0,1)) { @@ -107,7 +105,10 @@ void Part2DObject::positionBySupport(void) Place = Base::Placement(Base::Vector3d(0,0,0),Base::Rotation(Reverse ? -0.5 : 0.5,0.5,0.5, Reverse ? -0.5 : 0.5)); } - Reverse = false; // We already reversed... + if (Reverse) { + dir *= -1.0; + Reverse = false; // We already reversed... + } Place.getRotation().multVec(Base::Vector3d(0,0,1),dir); Base::Vector3d pos = Place.getPosition(); diff --git a/src/Mod/PartDesign/App/Body.h b/src/Mod/PartDesign/App/Body.h index dd07b0459..345a90308 100644 --- a/src/Mod/PartDesign/App/Body.h +++ b/src/Mod/PartDesign/App/Body.h @@ -33,7 +33,7 @@ namespace PartDesign class Feature; -class Body : public Part::BodyBase +class PartDesignExport Body : public Part::BodyBase { PROPERTY_HEADER(PartDesign::Body); diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt index 9578300e5..77d3cb68a 100644 --- a/src/Mod/PartDesign/App/CMakeLists.txt +++ b/src/Mod/PartDesign/App/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS} ${OCC_INCLUDE_DIR} + ${QT_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${XercesC_INCLUDE_DIRS} diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index bbdec5054..e074842a9 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -121,11 +121,11 @@ void CmdPartDesignBody::activated(int iMsg) doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[0]); doCommand(Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XY-Plane").toStdString().c_str()); doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[1]); + doCommand(Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,0,0),-90))"); + doCommand(Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XZ-Plane").toStdString().c_str()); + doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[2]); doCommand(Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,0),90))"); doCommand(Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str()); - doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[2]); - doCommand(Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,0,0),90))"); - doCommand(Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XZ-Plane").toStdString().c_str()); // ... and put them in the 'Origin' group doCommand(Doc,"App.activeDocument().addObject('App::DocumentObjectGroup','%s')", QObject::tr("Origin").toStdString().c_str()); for (unsigned i = 0; i < 3; i++) @@ -612,18 +612,19 @@ void CmdPartDesignNewSketch::activated(int iMsg) } // If there is more than one possibility, show dialog and let user pick plane + bool reversed = false; if (validPlanes > 1) { PartDesignGui::FeaturePickDialog Dlg(planes, status); if ((Dlg.exec() != QDialog::Accepted) || (planes = Dlg.getFeatures()).empty()) return; // Cancelled or nothing selected firstValidPlane = planes.begin(); + reversed = Dlg.getReverse(); } - // TODO: Allow user to choose front or back of the plane - App::Plane* plane = static_cast(*firstValidPlane); std::string FeatName = getUniqueObjectName("Sketch"); - std::string supportString = std::string("(App.activeDocument().") + plane->getNameInDocument() + ", ['front'])"; + std::string supportString = std::string("(App.activeDocument().") + plane->getNameInDocument() + + ", ['" + (reversed ? "back" : "front") + "'])"; openCommand("Create a new Sketch"); doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str()); diff --git a/src/Mod/PartDesign/Gui/FeaturePickDialog.cpp b/src/Mod/PartDesign/Gui/FeaturePickDialog.cpp index dc53a3f0c..9576b7bba 100644 --- a/src/Mod/PartDesign/Gui/FeaturePickDialog.cpp +++ b/src/Mod/PartDesign/Gui/FeaturePickDialog.cpp @@ -60,12 +60,14 @@ FeaturePickDialog::FeaturePickDialog(std::vector& objects, { ui->setupUi(this); + connect(ui->checkReverse, SIGNAL(toggled(bool)), this, SLOT(onCheckReverse(bool))); connect(ui->checkOtherBody, SIGNAL(toggled(bool)), this, SLOT(onCheckOtherBody(bool))); connect(ui->checkOtherFeature, SIGNAL(toggled(bool)), this, SLOT(onCheckOtherFeature(bool))); connect(ui->radioIndependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool))); connect(ui->radioDependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool))); connect(ui->radioXRef, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool))); + ui->checkReverse->setChecked(false); ui->checkOtherBody->setChecked(false); ui->checkOtherBody->setEnabled(false); // TODO: implement ui->checkOtherFeature->setChecked(false); @@ -114,6 +116,10 @@ void FeaturePickDialog::updateList() } } +void FeaturePickDialog::onCheckReverse(bool checked) +{ +} + void FeaturePickDialog::onCheckOtherFeature(bool checked) { ui->radioIndependent->setEnabled(checked); @@ -139,6 +145,11 @@ void FeaturePickDialog::onUpdate(bool) updateList(); } +bool FeaturePickDialog::getReverse() +{ + return ui->checkReverse->isChecked(); +} + std::vector FeaturePickDialog::getFeatures() { std::vector result; diff --git a/src/Mod/PartDesign/Gui/FeaturePickDialog.h b/src/Mod/PartDesign/Gui/FeaturePickDialog.h index 87f0140a6..b8f4097ba 100644 --- a/src/Mod/PartDesign/Gui/FeaturePickDialog.h +++ b/src/Mod/PartDesign/Gui/FeaturePickDialog.h @@ -49,14 +49,17 @@ public: ~FeaturePickDialog(); std::vector getFeatures(); + bool getReverse(); void accept(); protected Q_SLOTS: + void onCheckReverse(bool); void onCheckOtherFeature(bool); void onCheckOtherBody(bool); void onUpdate(bool); + private: Ui_FeaturePickDialog* ui; diff --git a/src/Mod/PartDesign/Gui/FeaturePickDialog.ui b/src/Mod/PartDesign/Gui/FeaturePickDialog.ui index 76e5e728a..47728c76b 100644 --- a/src/Mod/PartDesign/Gui/FeaturePickDialog.ui +++ b/src/Mod/PartDesign/Gui/FeaturePickDialog.ui @@ -7,7 +7,7 @@ 0 0 318 - 357 + 398 @@ -17,10 +17,24 @@ + + + + Reverse direction + + + + + + + Qt::Horizontal + + + - Allow sketch from other Body + Allow feature from other Body diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 02f278c78..d0daf7219 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -162,10 +162,10 @@ void switchToDocument(const App::Document* doc) if (SketchVector == Base::Vector3d(0,0,1)) { Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = (App.activeDocument().%s,['%s'])", sketch->getNameInDocument(), BaseplaneNames[0], side.c_str()); - } else if (SketchVector == Base::Vector3d(1,0,0)) { + } else if (SketchVector == Base::Vector3d(0,1,0)) { Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = (App.activeDocument().%s,['%s'])", sketch->getNameInDocument(), BaseplaneNames[1], side.c_str()); - } else if (SketchVector == Base::Vector3d(0,1,0)) { + } else if (SketchVector == Base::Vector3d(1,0,0)) { Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = (App.activeDocument().%s,['%s'])", sketch->getNameInDocument(), BaseplaneNames[2], side.c_str()); } else { @@ -206,11 +206,11 @@ void switchToDocument(const App::Document* doc) Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[0]); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XY-Plane").toStdString().c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[1]); - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,0),90))"); - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[2]); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,0,0),90))"); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XZ-Plane").toStdString().c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[2]); + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,0),90))"); + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str()); // ... and put them in the 'Origin' group Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::DocumentObjectGroup','%s')", QObject::tr("Origin").toStdString().c_str()); for (unsigned i = 0; i < 3; i++) diff --git a/src/Mod/Start/StartPage/PartDesign.py b/src/Mod/Start/StartPage/PartDesign.py index fc77976f6..8aa1c7b6b 100644 --- a/src/Mod/Start/StartPage/PartDesign.py +++ b/src/Mod/Start/StartPage/PartDesign.py @@ -22,8 +22,9 @@ #*************************************************************************** import FreeCADGui -FreeCADGui.activateWorkbench("PartDesignWorkbench") +Gui.activateWorkbench("PartDesignWorkbench") App.newDocument() # Make the planes properly visible -FreeCADGui.activeDocument().activeView().viewAxometric() -FreeCADGui.SendMsgToActiveView("ViewFit") +#Gui.ActiveDocument.ActiveView.setCameraOrientation(App.ActiveDocument.BaseplaneXY.Placement.Rotation.Q) +#Gui.activeDocument().activeView().viewAxometric() +#Gui.SendMsgToActiveView("ViewFit")