make origin lines usable in groove
This commit is contained in:
parent
ec125cf9f2
commit
d8a0e398a9
|
@ -1041,9 +1041,9 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std:
|
|||
base = line->getBasePoint();
|
||||
dir = line->getDirection();
|
||||
|
||||
// Check that axis is co-planar with sketch plane!
|
||||
if (!sketchplane.Contains(gp_Lin(gp_Pnt(base.x, base.y, base.z), gp_Dir(dir.x, dir.y, dir.z)), Precision::Confusion(), Precision::Confusion()))
|
||||
throw Base::Exception("Rotation axis must be coplanar with the sketch plane");
|
||||
// Check that axis is perpendicular with sketch plane!
|
||||
if (sketchplane.Axis().Direction().Angle(gp_Dir(dir.x, dir.y, dir.z))< Precision::Angular())
|
||||
throw Base::Exception("Rotation axis must not be perpendicular with the sketch plane");
|
||||
}
|
||||
else if (pcReferenceAxis->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
const App::Line* line = static_cast<const App::Line*>(pcReferenceAxis);
|
||||
|
@ -1055,9 +1055,9 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std:
|
|||
else if( strcmp(line->getNameInDocument(), App::Part::BaselineTypes[2]) == 0)
|
||||
dir = Base::Vector3d(0,0,1);
|
||||
|
||||
// Check that axis is co-planar with sketch plane!
|
||||
if (!sketchplane.Contains(gp_Lin(gp_Pnt(base.x, base.y, base.z), gp_Dir(dir.x, dir.y, dir.z)), Precision::Confusion(), Precision::Confusion()))
|
||||
throw Base::Exception("Rotation axis must be coplanar with the sketch plane");
|
||||
// Check that axis is perpendicular with sketch plane!
|
||||
if (sketchplane.Axis().Direction().Angle(gp_Dir(dir.x, dir.y, dir.z)) < Precision::Angular())
|
||||
throw Base::Exception("Rotation axis must not be perpendicular with the sketch plane");
|
||||
}
|
||||
else if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
|
||||
if (subReferenceAxis[0].empty())
|
||||
|
@ -1079,8 +1079,9 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std:
|
|||
gp_Dir d = adapt.Line().Direction();
|
||||
dir = Base::Vector3d(d.X(), d.Y(), d.Z());
|
||||
// Check that axis is co-planar with sketch plane!
|
||||
if (!sketchplane.Contains(adapt.Line(), Precision::Confusion(), Precision::Confusion()))
|
||||
throw Base::Exception("Rotation axis must be coplanar with the sketch plane");
|
||||
// Check that axis is perpendicular with sketch plane!
|
||||
if (sketchplane.Axis().Direction().Angle(d) < Precision::Angular())
|
||||
throw Base::Exception("Rotation axis must not be perpendicular with the sketch plane");
|
||||
} else {
|
||||
throw Base::Exception("Rotation reference must be an edge");
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <Base/UnitsApi.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -39,6 +41,7 @@
|
|||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/ViewProviderOrigin.h>
|
||||
#include <Mod/PartDesign/App/DatumLine.h>
|
||||
#include <Mod/PartDesign/App/FeatureGroove.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
@ -100,6 +103,21 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge
|
|||
ui->checkBoxReversed->blockSignals(false);
|
||||
|
||||
setFocus ();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(vp->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::updateUI()
|
||||
|
@ -115,23 +133,30 @@ void TaskGrooveParameters::updateUI()
|
|||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
|
||||
int maxcount=2;
|
||||
int maxcount=5;
|
||||
if (pcSketch)
|
||||
maxcount += pcSketch->getAxisCount();
|
||||
|
||||
for (int i=ui->axis->count()-1; i >= 2; i--)
|
||||
for (int i=ui->axis->count()-1; i >= 5; i--)
|
||||
ui->axis->removeItem(i);
|
||||
for (int i=ui->axis->count(); i < maxcount; i++)
|
||||
ui->axis->addItem(QString::fromAscii("Sketch axis %1").arg(i-5));
|
||||
|
||||
bool undefined = false;
|
||||
if (pcReferenceAxis != NULL && !sub.empty()) {
|
||||
if (sub.front() == "H_Axis")
|
||||
bool undefined = false;
|
||||
if (pcReferenceAxis != NULL) {
|
||||
|
||||
if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[0])==0)
|
||||
ui->axis->setCurrentIndex(0);
|
||||
else if (sub.front() == "V_Axis")
|
||||
else if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[1])==0)
|
||||
ui->axis->setCurrentIndex(1);
|
||||
else if (sub.front().size() > 4 && sub.front().substr(0,4) == "Axis") {
|
||||
int pos = 2 + std::atoi(sub.front().substr(4,4000).c_str());
|
||||
else if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[2])==0)
|
||||
ui->axis->setCurrentIndex(2);
|
||||
else if (!sub.empty() && sub.front() == "H_Axis")
|
||||
ui->axis->setCurrentIndex(3);
|
||||
else if (!sub.empty() && sub.front() == "V_Axis")
|
||||
ui->axis->setCurrentIndex(4);
|
||||
else if (!sub.empty() && sub.front().size() > 4 && sub.front().substr(0,4) == "Axis") {
|
||||
int pos = 5 + std::atoi(sub.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->axis->setCurrentIndex(pos);
|
||||
else
|
||||
|
@ -203,12 +228,24 @@ void TaskGrooveParameters::onAxisChanged(int num)
|
|||
|
||||
int maxcount = pcSketch->getAxisCount()+2;
|
||||
if (num == 0) {
|
||||
pcGroove->ReferenceAxis.setValue(pcGroove->getDocument()->getObject(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcGroove->ReferenceAxis.setValue(pcGroove->getDocument()->getObject(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 2) {
|
||||
pcGroove->ReferenceAxis.setValue(pcGroove->getDocument()->getObject(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 3) {
|
||||
pcGroove->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
exitSelectionMode();
|
||||
} else if (num == 1) {
|
||||
} else if (num == 4) {
|
||||
pcGroove->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,"V_Axis"));
|
||||
exitSelectionMode();
|
||||
} else if (num >= 2 && num < maxcount) {
|
||||
} else if (num >= 5 && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-2);
|
||||
std::string str = buf.toStdString();
|
||||
pcGroove->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
|
@ -263,17 +300,23 @@ void TaskGrooveParameters::getReferenceAxis(App::DocumentObject*& obj, std::vect
|
|||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
obj = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
|
||||
sub = std::vector<std::string>(1,"");
|
||||
int maxcount=2;
|
||||
int maxcount=5;
|
||||
if (obj)
|
||||
maxcount += static_cast<Part::Part2DObject*>(obj)->getAxisCount();
|
||||
|
||||
if (obj) {
|
||||
int num = ui->axis->currentIndex();
|
||||
if (num == 0)
|
||||
if(num == 0)
|
||||
obj = pcGroove->getDocument()->getObject(App::Part::BaselineTypes[0]);
|
||||
else if(num == 1)
|
||||
obj = pcGroove->getDocument()->getObject(App::Part::BaselineTypes[1]);
|
||||
else if(num == 2)
|
||||
obj = pcGroove->getDocument()->getObject(App::Part::BaselineTypes[2]);
|
||||
else if (num == 3)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 1)
|
||||
else if (num == 4)
|
||||
sub[0] = "V_Axis";
|
||||
else if (num >= 2 && num < maxcount) {
|
||||
else if (num >= 5 && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-2);
|
||||
sub[0] = buf.toStdString();
|
||||
} else if (num == maxcount && ui->axis->count() == maxcount + 2) {
|
||||
|
@ -301,6 +344,20 @@ bool TaskGrooveParameters::getReversed(void) const
|
|||
|
||||
TaskGrooveParameters::~TaskGrooveParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(vp->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,21 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="axis">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Base X axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Base Y axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Base Z axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Horizontal sketch axis</string>
|
||||
|
@ -54,20 +69,20 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="grooveAngle">
|
||||
<widget class="Gui::QuantitySpinBox" name="grooveAngle" native="true">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">deg</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<property name="minimum" stdset="0">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<property name="maximum" stdset="0">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<property name="singleStep" stdset="0">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<property name="value" stdset="0">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in New Issue
Block a user