make origin lines usable in revolution
This commit is contained in:
parent
c5ae4530ab
commit
ec125cf9f2
|
@ -71,6 +71,8 @@
|
|||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Line.h>
|
||||
#include <App/Part.h>
|
||||
#include <Mod/Part/App/modelRefine.h>
|
||||
#include "FeatureSketchBased.h"
|
||||
#include "DatumPlane.h"
|
||||
|
@ -1042,7 +1044,22 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std:
|
|||
// 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");
|
||||
} else if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
|
||||
}
|
||||
else if (pcReferenceAxis->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
const App::Line* line = static_cast<const App::Line*>(pcReferenceAxis);
|
||||
base = Base::Vector3d(0,0,0);
|
||||
if( strcmp(line->getNameInDocument(), App::Part::BaselineTypes[0]) == 0)
|
||||
dir = Base::Vector3d(1,0,0);
|
||||
else if( strcmp(line->getNameInDocument(), App::Part::BaselineTypes[1]) == 0)
|
||||
dir = Base::Vector3d(0,1,0);
|
||||
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");
|
||||
}
|
||||
else if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
|
||||
if (subReferenceAxis[0].empty())
|
||||
throw Base::Exception("No rotation axis reference specified");
|
||||
const Part::Feature* refFeature = static_cast<const Part::Feature*>(pcReferenceAxis);
|
||||
|
|
|
@ -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/FeatureRevolution.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
@ -100,6 +103,21 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol
|
|||
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(RevolutionView->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 TaskRevolutionParameters::updateUI()
|
||||
|
@ -115,23 +133,29 @@ void TaskRevolutionParameters::updateUI()
|
|||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->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")
|
||||
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
|
||||
|
@ -167,7 +191,7 @@ void TaskRevolutionParameters::onSelectionChanged(const Gui::SelectionChanges& m
|
|||
}
|
||||
else {
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
int maxcount=2;
|
||||
int maxcount=5;
|
||||
if (pcSketch)
|
||||
maxcount += pcSketch->getAxisCount();
|
||||
for (int i=ui->axis->count()-1; i >= maxcount; i--)
|
||||
|
@ -202,14 +226,26 @@ void TaskRevolutionParameters::onAxisChanged(int num)
|
|||
App::DocumentObject *oldRefAxis = pcRevolution->ReferenceAxis.getValue();
|
||||
std::vector<std::string> oldSubRefAxis = pcRevolution->ReferenceAxis.getSubValues();
|
||||
|
||||
int maxcount = pcSketch->getAxisCount()+2;
|
||||
int maxcount = pcSketch->getAxisCount()+5;
|
||||
if (num == 0) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 2) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 3) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
exitSelectionMode();
|
||||
} else if (num == 1) {
|
||||
} else if (num == 4) {
|
||||
pcRevolution->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();
|
||||
pcRevolution->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
|
@ -264,17 +300,23 @@ void TaskRevolutionParameters::getReferenceAxis(App::DocumentObject*& obj, std::
|
|||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
obj = static_cast<Sketcher::SketchObject*>(pcRevolution->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 = pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[0]);
|
||||
else if(num == 1)
|
||||
obj = pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[1]);
|
||||
else if(num == 2)
|
||||
obj = pcRevolution->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) {
|
||||
|
@ -302,6 +344,20 @@ bool TaskRevolutionParameters::getReversed(void) const
|
|||
|
||||
TaskRevolutionParameters::~TaskRevolutionParameters()
|
||||
{
|
||||
//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="revolveAngle">
|
||||
<widget class="Gui::QuantitySpinBox" name="revolveAngle" 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