PartDesign: rework axis and plane comboboxes and make it work without part.
Rework combobox filling and link hadling for revolution and transformed features, in order to get rid of hard-coded item indexes and make the lists more dynamic.
This commit is contained in:
parent
2625233dff
commit
9776d30b87
|
@ -153,19 +153,14 @@ void TaskLinearPatternParameters::setupUI()
|
|||
ui->spinLength->blockSignals(false);
|
||||
ui->spinOccurrences->setEnabled(true);
|
||||
|
||||
|
||||
dirLinks.setCombo(*(ui->comboDirection));
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
if (sketch) {
|
||||
ui->comboDirection->addItem(QString::fromAscii("Horizontal sketch axis"));
|
||||
ui->comboDirection->addItem(QString::fromAscii("Vertical sketch axis"));
|
||||
}
|
||||
//add the base axes to the selection combo box
|
||||
ui->comboDirection->addItem(QString::fromAscii("Base X axis"));
|
||||
ui->comboDirection->addItem(QString::fromAscii("Base Y axis"));
|
||||
ui->comboDirection->addItem(QString::fromAscii("Base Z axis"));
|
||||
ui->comboDirection->addItem(QString::fromAscii("Select reference..."));
|
||||
if (!sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
sketch = 0;
|
||||
this->fillAxisCombo(dirLinks,static_cast<Part::Part2DObject*>(sketch));
|
||||
|
||||
updateUI();
|
||||
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
|
@ -176,7 +171,7 @@ void TaskLinearPatternParameters::setupUI()
|
|||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::updateUI()
|
||||
|
@ -187,62 +182,16 @@ void TaskLinearPatternParameters::updateUI()
|
|||
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* directionFeature = pcLinearPattern->Direction.getValue();
|
||||
std::vector<std::string> directions = pcLinearPattern->Direction.getSubValues();
|
||||
bool reverse = pcLinearPattern->Reversed.getValue();
|
||||
double length = pcLinearPattern->Length.getValue();
|
||||
unsigned occurrences = pcLinearPattern->Occurrences.getValue();
|
||||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (sketch) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
if (dirLinks.setCurrentLink(pcLinearPattern->Direction) == -1){
|
||||
//failed to set current, because the link isnt in the list yet
|
||||
dirLinks.addLink(pcLinearPattern->Direction, getRefStr(pcLinearPattern->Direction.getValue(),pcLinearPattern->Direction.getSubValues()));
|
||||
dirLinks.setCurrentLink(pcLinearPattern->Direction);
|
||||
}
|
||||
|
||||
for (int i=ui->comboDirection->count()-1; i >= maxcount; i--)
|
||||
ui->comboDirection->removeItem(i);
|
||||
for (int i=ui->comboDirection->count(); i < maxcount; i++)
|
||||
ui->comboDirection->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
|
||||
|
||||
bool undefined = false;
|
||||
if (directionFeature != NULL && !directions.empty()) {
|
||||
bool is_base_line = directionFeature->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if (directions.front() == "H_Axis")
|
||||
ui->comboDirection->setCurrentIndex(0);
|
||||
else if (directions.front() == "V_Axis")
|
||||
ui->comboDirection->setCurrentIndex(1);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
ui->comboDirection->setCurrentIndex( sketch ? 2 : 0);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 3 : 1);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 4 : 2);
|
||||
else if (directions.front().size() > (sketch ? 4 : 2) && directions.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(directions.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->comboDirection->setCurrentIndex(pos);
|
||||
else
|
||||
undefined = true;
|
||||
} else {
|
||||
ui->comboDirection->addItem(getRefStr(directionFeature, directions));
|
||||
ui->comboDirection->setCurrentIndex(maxcount);
|
||||
}
|
||||
} else {
|
||||
undefined = true;
|
||||
}
|
||||
|
||||
if (selectionMode == reference) {
|
||||
ui->comboDirection->addItem(tr("Select an edge/face or datum line/plane"));
|
||||
ui->comboDirection->setCurrentIndex(ui->comboDirection->count() - 1);
|
||||
} else if (undefined) {
|
||||
ui->comboDirection->addItem(tr("Undefined"));
|
||||
ui->comboDirection->setCurrentIndex(ui->comboDirection->count() - 1);
|
||||
} else
|
||||
ui->comboDirection->addItem(tr("Select reference..."));
|
||||
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for blockUpdate
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
|
@ -275,32 +224,14 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
|
|||
} else if (selectionMode == reference) {
|
||||
// Note: ReferenceSelection has already checked the selection for validity
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
|
||||
pcLinearPattern->Direction.setValue(selObj, directions);
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
|
||||
pcLinearPattern->Direction.setValue(selObj, directions);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=5;
|
||||
if (sketch)
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
for (int i=ui->comboDirection->count()-1; i >= maxcount; i--)
|
||||
ui->comboDirection->removeItem(i);
|
||||
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
|
||||
ui->comboDirection->addItem(getRefStr(selObj, directions));
|
||||
ui->comboDirection->setCurrentIndex(maxcount);
|
||||
ui->comboDirection->addItem(tr("Select reference..."));
|
||||
}
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
|
||||
|
@ -357,55 +288,21 @@ void TaskLinearPatternParameters::onDirectionChanged(int num) {
|
|||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* pcSketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (pcSketch) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount();
|
||||
}
|
||||
|
||||
if(pcSketch) {
|
||||
if (num == 0) {
|
||||
pcLinearPattern->Direction.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcLinearPattern->Direction.setValue(pcSketch, std::vector<std::string>(1,"V_Axis"));
|
||||
try{
|
||||
if(dirLinks.getCurrentLink().getValue() == 0){
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, true);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
pcLinearPattern->Direction.Paste(dirLinks.getCurrentLink());
|
||||
}
|
||||
} catch (Base::Exception &e) {
|
||||
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
|
||||
}
|
||||
if (num == (pcSketch ? 2 : 0)) {
|
||||
pcLinearPattern->Direction.setValue(getPartLines(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 3 : 1)) {
|
||||
pcLinearPattern->Direction.setValue(getPartLines(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 4 : 2)) {
|
||||
pcLinearPattern->Direction.setValue(getPartLines(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num >= (pcSketch ? 5 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(pcSketch ? 5 : 3));
|
||||
std::string str = buf.toStdString();
|
||||
pcLinearPattern->Direction.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == ui->comboDirection->count() - 1) {
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, true);
|
||||
}
|
||||
else if (num == maxcount)
|
||||
exitSelectionMode();
|
||||
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
@ -441,38 +338,9 @@ void TaskLinearPatternParameters::onFeatureDeleted(void)
|
|||
|
||||
void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
{
|
||||
obj = getSketchObject();
|
||||
sub = std::vector<std::string>(1,"");
|
||||
int maxcount=3;
|
||||
if (obj) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(obj)->getAxisCount();
|
||||
}
|
||||
|
||||
int num = ui->comboDirection->currentIndex();
|
||||
if(obj) {
|
||||
if (num == 0)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 1)
|
||||
sub[0] = "V_Axis";
|
||||
}
|
||||
if (num == (obj ? 2 : 0))
|
||||
obj = getPartLines(App::Part::BaselineTypes[0]);
|
||||
else if (num == (obj ? 3 : 1))
|
||||
obj = getPartLines(App::Part::BaselineTypes[1]);
|
||||
else if (num == (obj ? 4 : 2))
|
||||
obj = getPartLines(App::Part::BaselineTypes[2]);
|
||||
else if (num >= (obj ? 5 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(obj ? 5 : 3));
|
||||
sub[0] = buf.toStdString();
|
||||
} else if (num == maxcount && ui->comboDirection->count() == maxcount + 2) {
|
||||
QStringList parts = ui->comboDirection->currentText().split(QChar::fromAscii(':'));
|
||||
obj = getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
|
||||
if (parts.size() > 1)
|
||||
sub[0] = parts[1].toStdString();
|
||||
} else {
|
||||
obj = NULL;
|
||||
}
|
||||
const App::PropertyLinkSub &lnk = dirLinks.getCurrentLink();
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
|
||||
const bool TaskLinearPatternParameters::getReverse(void) const
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#include <Base/UnitsApi.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -44,6 +47,7 @@
|
|||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/ViewProviderOrigin.h>
|
||||
#include <Mod/PartDesign/App/FeatureLinearPattern.h>
|
||||
#include <Mod/PartDesign/App/DatumPlane.h>
|
||||
#include <Mod/PartDesign/App/DatumLine.h>
|
||||
|
@ -133,11 +137,7 @@ void TaskLinearPatternParameters::setupUI()
|
|||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1((*i)->getNameInDocument()));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
|
@ -152,7 +152,26 @@ void TaskLinearPatternParameters::setupUI()
|
|||
ui->spinLength->setUnit(Base::Unit::Length);
|
||||
ui->spinLength->blockSignals(false);
|
||||
ui->spinOccurrences->setEnabled(true);
|
||||
|
||||
dirLinks.setCombo(*(ui->comboDirection));
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
if (!sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
sketch = 0;
|
||||
this->fillAxisCombo(dirLinks,static_cast<Part::Part2DObject*>(sketch));
|
||||
|
||||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::updateUI()
|
||||
|
@ -163,37 +182,38 @@ void TaskLinearPatternParameters::updateUI()
|
|||
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* directionFeature = pcLinearPattern->Direction.getValue();
|
||||
std::vector<std::string> directions = pcLinearPattern->Direction.getSubValues();
|
||||
bool reverse = pcLinearPattern->Reversed.getValue();
|
||||
double length = pcLinearPattern->Length.getValue();
|
||||
unsigned occurrences = pcLinearPattern->Occurrences.getValue();
|
||||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=5;
|
||||
if (sketch)
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
if (dirLinks.setCurrentLink(pcLinearPattern->Direction) == -1){
|
||||
//failed to set current, because the link isnt in the list yet
|
||||
dirLinks.addLink(pcLinearPattern->Direction, getRefStr(pcLinearPattern->Direction.getValue(),pcLinearPattern->Direction.getSubValues()));
|
||||
dirLinks.setCurrentLink(pcLinearPattern->Direction);
|
||||
}
|
||||
|
||||
for (int i=ui->comboDirection->count()-1; i >= 5; i--)
|
||||
<<<<<<< 05d084614fa15ead10b7283f4f36e3e587279953
|
||||
for (int i=ui->comboDirection->count()-1; i >= maxcount; i--)
|
||||
ui->comboDirection->removeItem(i);
|
||||
for (int i=ui->comboDirection->count(); i < maxcount; i++)
|
||||
ui->comboDirection->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
|
||||
|
||||
bool undefined = false;
|
||||
if (directionFeature != NULL && !directions.empty()) {
|
||||
bool is_base_line = directionFeature->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if (directions.front() == "H_Axis")
|
||||
ui->comboDirection->setCurrentIndex(0);
|
||||
else if (directions.front() == "V_Axis")
|
||||
ui->comboDirection->setCurrentIndex(1);
|
||||
else if (strcmp(directionFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[0]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(2);
|
||||
else if (strcmp(directionFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[1]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(3);
|
||||
else if (strcmp(directionFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[2]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(4);
|
||||
else if (directions.front().size() > 4 && directions.front().substr(0,4) == "Axis") {
|
||||
int pos = 5 + std::atoi(directions.front().substr(4,4000).c_str());
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
ui->comboDirection->setCurrentIndex( sketch ? 2 : 0);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 3 : 1);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 4 : 2);
|
||||
else if (directions.front().size() > (sketch ? 4 : 2) && directions.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(directions.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->comboDirection->setCurrentIndex(pos);
|
||||
else
|
||||
|
@ -215,6 +235,8 @@ void TaskLinearPatternParameters::updateUI()
|
|||
} else
|
||||
ui->comboDirection->addItem(tr("Select reference..."));
|
||||
|
||||
=======
|
||||
>>>>>>> PartDesign: rework axis and plane comboboxes and make it work without part.
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for blockUpdate
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
|
@ -239,11 +261,7 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
|
|||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
if (originalSelected(msg)) {
|
||||
if (selectionMode == addFeature)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1(msg.pObjectName));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii(msg.pObjectName));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName));
|
||||
else
|
||||
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
|
||||
|
||||
|
@ -251,32 +269,26 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
|
|||
} else if (selectionMode == reference) {
|
||||
// Note: ReferenceSelection has already checked the selection for validity
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
|
||||
pcLinearPattern->Direction.setValue(selObj, directions);
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
|
||||
pcLinearPattern->Direction.setValue(selObj, directions);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=5;
|
||||
if (sketch)
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
for (int i=ui->comboDirection->count()-1; i >= maxcount; i--)
|
||||
ui->comboDirection->removeItem(i);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
|
||||
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
|
||||
pcLinearPattern->Direction.setValue(selObj, directions);
|
||||
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
|
||||
ui->comboDirection->addItem(getRefStr(selObj, directions));
|
||||
ui->comboDirection->setCurrentIndex(maxcount);
|
||||
ui->comboDirection->addItem(tr("Select reference..."));
|
||||
}
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -321,51 +333,21 @@ void TaskLinearPatternParameters::onDirectionChanged(int num) {
|
|||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* pcSketch = getSketchObject();
|
||||
int maxcount=5;
|
||||
if (pcSketch)
|
||||
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount();
|
||||
|
||||
if (num == 0) {
|
||||
pcLinearPattern->Direction.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
exitSelectionMode();
|
||||
try{
|
||||
if(dirLinks.getCurrentLink().getValue() == 0){
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, true);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
pcLinearPattern->Direction.Paste(dirLinks.getCurrentLink());
|
||||
}
|
||||
} catch (Base::Exception &e) {
|
||||
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcLinearPattern->Direction.setValue(pcSketch, std::vector<std::string>(1,"V_Axis"));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 2) {
|
||||
pcLinearPattern->Direction.setValue(getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 3) {
|
||||
pcLinearPattern->Direction.setValue(getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 4) {
|
||||
pcLinearPattern->Direction.setValue(getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num >= 5 && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-5);
|
||||
std::string str = buf.toStdString();
|
||||
pcLinearPattern->Direction.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == ui->comboDirection->count() - 1) {
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, true);
|
||||
}
|
||||
else if (num == maxcount)
|
||||
exitSelectionMode();
|
||||
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
@ -401,34 +383,9 @@ void TaskLinearPatternParameters::onFeatureDeleted(void)
|
|||
|
||||
void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
{
|
||||
obj = getSketchObject();
|
||||
sub = std::vector<std::string>(1,"");
|
||||
int maxcount=5;
|
||||
if (obj)
|
||||
maxcount += static_cast<Part::Part2DObject*>(obj)->getAxisCount();
|
||||
|
||||
int num = ui->comboDirection->currentIndex();
|
||||
if (num == 0)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 1)
|
||||
sub[0] = "V_Axis";
|
||||
else if (num == 2)
|
||||
obj = getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[0]);
|
||||
else if (num == 3)
|
||||
obj = getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[1]);
|
||||
else if (num == 4)
|
||||
obj = getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[2]);
|
||||
else if (num >= 5 && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-5);
|
||||
sub[0] = buf.toStdString();
|
||||
} else if (num == maxcount && ui->comboDirection->count() == maxcount + 2) {
|
||||
QStringList parts = ui->comboDirection->currentText().split(QChar::fromAscii(':'));
|
||||
obj = getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
|
||||
if (parts.size() > 1)
|
||||
sub[0] = parts[1].toStdString();
|
||||
} else {
|
||||
obj = NULL;
|
||||
}
|
||||
const App::PropertyLinkSub &lnk = dirLinks.getCurrentLink();
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
|
||||
const bool TaskLinearPatternParameters::getReverse(void) const
|
||||
|
@ -449,6 +406,17 @@ const unsigned TaskLinearPatternParameters::getOccurrences(void) const
|
|||
|
||||
TaskLinearPatternParameters::~TaskLinearPatternParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
if (proxy)
|
||||
delete proxy;
|
||||
|
@ -470,10 +438,11 @@ void TaskLinearPatternParameters::apply()
|
|||
App::DocumentObject* obj;
|
||||
getDirection(obj, directions);
|
||||
std::string direction = getPythonStr(obj, directions);
|
||||
if (!direction.empty()) {
|
||||
if (!direction.empty() && obj) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), direction.c_str());
|
||||
} else
|
||||
} else {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str());
|
||||
}
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),getReverse());
|
||||
|
||||
ui->spinLength->apply();
|
||||
|
|
|
@ -85,6 +85,8 @@ private:
|
|||
private:
|
||||
Ui_TaskLinearPatternParameters* ui;
|
||||
QTimer* updateViewTimer;
|
||||
|
||||
ComboLinks dirLinks;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -125,18 +125,15 @@ void TaskMirroredParameters::setupUI()
|
|||
}
|
||||
// ---------------------
|
||||
|
||||
this->planeLinks.setCombo(*(ui->comboPlane));
|
||||
ui->comboPlane->setEnabled(true);
|
||||
|
||||
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
if (sketch) {
|
||||
ui->comboPlane->addItem(QString::fromAscii("Horizontal sketch axis"));
|
||||
ui->comboPlane->addItem(QString::fromAscii("Vertical sketch axis"));
|
||||
}
|
||||
//add the base axes to the selection combo box
|
||||
ui->comboPlane->addItem(QString::fromAscii("Base XY axis"));
|
||||
ui->comboPlane->addItem(QString::fromAscii("Base XZ axis"));
|
||||
ui->comboPlane->addItem(QString::fromAscii("Base YZ axis"));
|
||||
ui->comboPlane->addItem(QString::fromAscii("Select reference..."));
|
||||
if (!sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
sketch = 0;
|
||||
this->fillPlanesCombo(planeLinks,static_cast<Part::Part2DObject*>(sketch));
|
||||
|
||||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
|
@ -160,59 +157,12 @@ void TaskMirroredParameters::updateUI()
|
|||
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
|
||||
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
|
||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
||||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (sketch) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
if (planeLinks.setCurrentLink(pcMirrored->MirrorPlane) == -1){
|
||||
//failed to set current, because the link isnt in the list yet
|
||||
planeLinks.addLink(pcMirrored->MirrorPlane, getRefStr(pcMirrored->MirrorPlane.getValue(),pcMirrored->MirrorPlane.getSubValues()));
|
||||
planeLinks.setCurrentLink(pcMirrored->MirrorPlane);
|
||||
}
|
||||
|
||||
for (int i=ui->comboPlane->count()-1; i >= (sketch ? 5 : 3); i--)
|
||||
ui->comboPlane->removeItem(i);
|
||||
for (int i=ui->comboPlane->count(); i < maxcount; i++)
|
||||
ui->comboPlane->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
|
||||
|
||||
bool undefined = false;
|
||||
if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
|
||||
bool is_base_plane = mirrorPlaneFeature->isDerivedFrom(App::Plane::getClassTypeId());
|
||||
|
||||
if (mirrorPlanes.front() == "H_Axis")
|
||||
ui->comboPlane->setCurrentIndex(0);
|
||||
else if (mirrorPlanes.front() == "V_Axis")
|
||||
ui->comboPlane->setCurrentIndex(1);
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 2 : 0));
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 3 : 1));
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 4 : 2));
|
||||
else if (mirrorPlanes.front().size() > (sketch ? 4 : 2) && mirrorPlanes.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(mirrorPlanes.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->comboPlane->setCurrentIndex(pos);
|
||||
else
|
||||
undefined = true;
|
||||
} else {
|
||||
ui->comboPlane->addItem(getRefStr(mirrorPlaneFeature, mirrorPlanes));
|
||||
ui->comboPlane->setCurrentIndex(maxcount);
|
||||
}
|
||||
} else {
|
||||
undefined = true;
|
||||
}
|
||||
|
||||
if (selectionMode == reference) {
|
||||
ui->comboPlane->addItem(tr("Select a face or datum plane"));
|
||||
ui->comboPlane->setCurrentIndex(ui->comboPlane->count() - 1);
|
||||
} else if (undefined) {
|
||||
ui->comboPlane->addItem(tr("Undefined"));
|
||||
ui->comboPlane->setCurrentIndex(ui->comboPlane->count() - 1);
|
||||
} else
|
||||
ui->comboPlane->addItem(tr("Select reference..."));
|
||||
|
||||
blockUpdate = false;
|
||||
}
|
||||
|
||||
|
@ -229,34 +179,15 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
|
|||
} else if (selectionMode == reference) {
|
||||
// Note: ReferenceSelection has already checked the selection for validity
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (sketch) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
}
|
||||
for (int i=ui->comboPlane->count()-1; i >= maxcount; i--)
|
||||
ui->comboPlane->removeItem(i);
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
|
||||
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
ui->comboPlane->addItem(getRefStr(selObj, mirrorPlanes));
|
||||
ui->comboPlane->setCurrentIndex(maxcount);
|
||||
ui->comboPlane->addItem(tr("Select reference..."));
|
||||
}
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaseplaneTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[2]) == nullptr) {
|
||||
|
@ -283,55 +214,21 @@ void TaskMirroredParameters::onPlaneChanged(int num) {
|
|||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
|
||||
App::DocumentObject* pcSketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (pcSketch) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount();
|
||||
}
|
||||
|
||||
if(pcSketch) {
|
||||
if (num == 0) {
|
||||
pcMirrored->MirrorPlane.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcMirrored->MirrorPlane.setValue(pcSketch, std::vector<std::string>(1,"V_Axis"));
|
||||
try{
|
||||
if(planeLinks.getCurrentLink().getValue() == 0){
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(false, true);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
pcMirrored->MirrorPlane.Paste(planeLinks.getCurrentLink());
|
||||
}
|
||||
} catch (Base::Exception &e) {
|
||||
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
|
||||
}
|
||||
if (num == (pcSketch ? 2 : 0)) {
|
||||
pcMirrored->MirrorPlane.setValue(getObject()->getDocument()->getObject(App::Part::BaseplaneTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 3 : 1)) {
|
||||
pcMirrored->MirrorPlane.setValue(getObject()->getDocument()->getObject(App::Part::BaseplaneTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 4 : 2)) {
|
||||
pcMirrored->MirrorPlane.setValue(getObject()->getDocument()->getObject(App::Part::BaseplaneTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num >= (pcSketch ? 5 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(pcSketch ? 5 : 3));
|
||||
std::string str = buf.toStdString();
|
||||
pcMirrored->MirrorPlane.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == ui->comboPlane->count() - 1) {
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(false, true);
|
||||
}
|
||||
else if (num == maxcount)
|
||||
exitSelectionMode();
|
||||
|
||||
recomputeFeature();
|
||||
}
|
||||
|
@ -362,40 +259,11 @@ void TaskMirroredParameters::onFeatureDeleted(void)
|
|||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::getMirrorPlane(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
void TaskMirroredParameters::getMirrorPlane(App::DocumentObject*& obj, std::vector<std::string> &sub) const
|
||||
{
|
||||
obj = getSketchObject();
|
||||
sub = std::vector<std::string>(1,"");
|
||||
int maxcount=3;
|
||||
if (obj) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(obj)->getAxisCount();
|
||||
}
|
||||
|
||||
int num = ui->comboPlane->currentIndex();
|
||||
if(obj) {
|
||||
if (num == 0)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 1)
|
||||
sub[0] = "V_Axis";
|
||||
}
|
||||
if (num == (obj ? 2 : 0))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaseplaneTypes[0]);
|
||||
else if (num == (obj ? 3 : 1))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaseplaneTypes[1]);
|
||||
else if (num == (obj ? 4 : 2))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaseplaneTypes[2]);
|
||||
else if (num >= (obj ? 5 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(obj ? 5 : 3));
|
||||
sub[0] = buf.toStdString();
|
||||
} else if (num == maxcount && ui->comboPlane->count() == maxcount + 2) {
|
||||
QStringList parts = ui->comboPlane->currentText().split(QChar::fromAscii(':'));
|
||||
obj = getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
|
||||
if (parts.size() > 1)
|
||||
sub[0] = parts[1].toStdString();
|
||||
} else {
|
||||
obj = NULL;
|
||||
}
|
||||
const App::PropertyLinkSub &lnk = planeLinks.getCurrentLink();
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::apply()
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include "ReferenceSelection.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Plane.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -42,6 +44,7 @@
|
|||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/ViewProviderOrigin.h>
|
||||
#include <Mod/PartDesign/App/DatumPlane.h>
|
||||
#include <Mod/PartDesign/App/FeatureMirrored.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
@ -118,16 +121,32 @@ void TaskMirroredParameters::setupUI()
|
|||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1((*i)->getNameInDocument()));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
this->planeLinks.setCombo(*(ui->comboPlane));
|
||||
ui->comboPlane->setEnabled(true);
|
||||
|
||||
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
if (!sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
sketch = 0;
|
||||
this->fillPlanesCombo(planeLinks,static_cast<Part::Part2DObject*>(sketch));
|
||||
|
||||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::updateUI()
|
||||
|
@ -138,34 +157,39 @@ void TaskMirroredParameters::updateUI()
|
|||
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
|
||||
<<<<<<< 05d084614fa15ead10b7283f4f36e3e587279953
|
||||
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
|
||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
||||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=5;
|
||||
if (sketch)
|
||||
int maxcount=3;
|
||||
if (sketch) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
}
|
||||
|
||||
for (int i=ui->comboPlane->count()-1; i >= 5; i--)
|
||||
for (int i=ui->comboPlane->count()-1; i >= (sketch ? 5 : 3); i--)
|
||||
ui->comboPlane->removeItem(i);
|
||||
for (int i=ui->comboPlane->count(); i < maxcount; i++)
|
||||
ui->comboPlane->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
|
||||
|
||||
bool undefined = false;
|
||||
if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
|
||||
bool is_base_plane = mirrorPlaneFeature->isDerivedFrom(App::Plane::getClassTypeId());
|
||||
|
||||
if (mirrorPlanes.front() == "H_Axis")
|
||||
ui->comboPlane->setCurrentIndex(0);
|
||||
else if (mirrorPlanes.front() == "V_Axis")
|
||||
ui->comboPlane->setCurrentIndex(1);
|
||||
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[0]) == 0)
|
||||
ui->comboPlane->setCurrentIndex(2);
|
||||
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[1]) == 0)
|
||||
ui->comboPlane->setCurrentIndex(3);
|
||||
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[2]) == 0)
|
||||
ui->comboPlane->setCurrentIndex(4);
|
||||
else if (mirrorPlanes.front().size() > 4 && mirrorPlanes.front().substr(0,4) == "Axis") {
|
||||
int pos = 5 + std::atoi(mirrorPlanes.front().substr(4,4000).c_str());
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 2 : 0));
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 3 : 1));
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 4 : 2));
|
||||
else if (mirrorPlanes.front().size() > (sketch ? 4 : 2) && mirrorPlanes.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(mirrorPlanes.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->comboPlane->setCurrentIndex(pos);
|
||||
else
|
||||
|
@ -176,17 +200,14 @@ void TaskMirroredParameters::updateUI()
|
|||
}
|
||||
} else {
|
||||
undefined = true;
|
||||
=======
|
||||
if (planeLinks.setCurrentLink(pcMirrored->MirrorPlane) == -1){
|
||||
//failed to set current, because the link isnt in the list yet
|
||||
planeLinks.addLink(pcMirrored->MirrorPlane, getRefStr(pcMirrored->MirrorPlane.getValue(),pcMirrored->MirrorPlane.getSubValues()));
|
||||
planeLinks.setCurrentLink(pcMirrored->MirrorPlane);
|
||||
>>>>>>> PartDesign: rework axis and plane comboboxes and make it work without part.
|
||||
}
|
||||
|
||||
if (selectionMode == reference) {
|
||||
ui->comboPlane->addItem(tr("Select a face or datum plane"));
|
||||
ui->comboPlane->setCurrentIndex(ui->comboPlane->count() - 1);
|
||||
} else if (undefined) {
|
||||
ui->comboPlane->addItem(tr("Undefined"));
|
||||
ui->comboPlane->setCurrentIndex(ui->comboPlane->count() - 1);
|
||||
} else
|
||||
ui->comboPlane->addItem(tr("Select reference..."));
|
||||
|
||||
blockUpdate = false;
|
||||
}
|
||||
|
||||
|
@ -196,43 +217,34 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
|
|||
|
||||
if (originalSelected(msg)) {
|
||||
if (selectionMode == addFeature)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1(msg.pObjectName));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii(msg.pObjectName));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName));
|
||||
else
|
||||
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
|
||||
exitSelectionMode();
|
||||
} else if (selectionMode == reference) {
|
||||
// Note: ReferenceSelection has already checked the selection for validity
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=5;
|
||||
if (sketch)
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
for (int i=ui->comboPlane->count()-1; i >= maxcount; i--)
|
||||
ui->comboPlane->removeItem(i);
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
|
||||
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
ui->comboPlane->addItem(getRefStr(selObj, mirrorPlanes));
|
||||
ui->comboPlane->setCurrentIndex(maxcount);
|
||||
ui->comboPlane->addItem(tr("Select reference..."));
|
||||
}
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaseplaneTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[2]) == nullptr) {
|
||||
|
||||
std::vector<std::string> planes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, planes);
|
||||
pcMirrored->MirrorPlane.setValue(selObj, planes);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,51 +259,21 @@ void TaskMirroredParameters::onPlaneChanged(int num) {
|
|||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
|
||||
App::DocumentObject* pcSketch = getSketchObject();
|
||||
int maxcount=5;
|
||||
if (pcSketch)
|
||||
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount();
|
||||
|
||||
if (num == 0) {
|
||||
pcMirrored->MirrorPlane.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
exitSelectionMode();
|
||||
try{
|
||||
if(planeLinks.getCurrentLink().getValue() == 0){
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(false, true);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
pcMirrored->MirrorPlane.Paste(planeLinks.getCurrentLink());
|
||||
}
|
||||
} catch (Base::Exception &e) {
|
||||
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcMirrored->MirrorPlane.setValue(pcSketch, std::vector<std::string>(1,"V_Axis"));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 2) {
|
||||
pcMirrored->MirrorPlane.setValue(getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 3) {
|
||||
pcMirrored->MirrorPlane.setValue(getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == 4) {
|
||||
pcMirrored->MirrorPlane.setValue(getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num >= 5 && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-5);
|
||||
std::string str = buf.toStdString();
|
||||
pcMirrored->MirrorPlane.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == ui->comboPlane->count() - 1) {
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(false, true);
|
||||
}
|
||||
else if (num == maxcount)
|
||||
exitSelectionMode();
|
||||
|
||||
recomputeFeature();
|
||||
}
|
||||
|
@ -322,36 +304,11 @@ void TaskMirroredParameters::onFeatureDeleted(void)
|
|||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::getMirrorPlane(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
void TaskMirroredParameters::getMirrorPlane(App::DocumentObject*& obj, std::vector<std::string> &sub) const
|
||||
{
|
||||
obj = getSketchObject();
|
||||
sub = std::vector<std::string>(1,"");
|
||||
int maxcount=5;
|
||||
if (obj)
|
||||
maxcount += static_cast<Part::Part2DObject*>(obj)->getAxisCount();
|
||||
|
||||
int num = ui->comboPlane->currentIndex();
|
||||
if (num == 0)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 1)
|
||||
sub[0] = "V_Axis";
|
||||
else if (num == 2)
|
||||
obj = getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[0]);
|
||||
else if (num == 3)
|
||||
obj = getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[1]);
|
||||
else if (num == 4)
|
||||
obj = getObject()->getDocument()->getObject(PartDesignGui::BaseplaneNames[2]);
|
||||
else if (num >= 5 && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-5);
|
||||
sub[0] = buf.toStdString();
|
||||
} else if (num == maxcount && ui->comboPlane->count() == maxcount + 2) {
|
||||
QStringList parts = ui->comboPlane->currentText().split(QChar::fromAscii(':'));
|
||||
obj = getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
|
||||
if (parts.size() > 1)
|
||||
sub[0] = parts[1].toStdString();
|
||||
} else {
|
||||
obj = NULL;
|
||||
}
|
||||
const App::PropertyLinkSub &lnk = planeLinks.getCurrentLink();
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::apply()
|
||||
|
@ -360,6 +317,18 @@ void TaskMirroredParameters::apply()
|
|||
|
||||
TaskMirroredParameters::~TaskMirroredParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delete ui;
|
||||
if (proxy)
|
||||
delete proxy;
|
||||
|
@ -401,10 +370,11 @@ bool TaskDlgMirroredParameters::accept()
|
|||
App::DocumentObject* obj;
|
||||
mirrorParameter->getMirrorPlane(obj, mirrorPlanes);
|
||||
std::string mirrorPlane = getPythonStr(obj, mirrorPlanes);
|
||||
if (!mirrorPlane.empty()) {
|
||||
if (!mirrorPlane.empty() && obj) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), mirrorPlane.c_str());
|
||||
} else
|
||||
} else {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
|
||||
}
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
if (!TransformedView->getObject()->isValid())
|
||||
throw Base::Exception(TransformedView->getObject()->getStatusString());
|
||||
|
|
|
@ -74,6 +74,7 @@ protected:
|
|||
private:
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
ComboLinks planeLinks;
|
||||
|
||||
private:
|
||||
Ui_TaskMirroredParameters* ui;
|
||||
|
|
|
@ -149,14 +149,10 @@ void TaskPolarPatternParameters::setupUI()
|
|||
ui->spinOccurrences->setEnabled(true);
|
||||
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
if (sketch) {
|
||||
ui->comboAxis->addItem(QString::fromAscii("Normal sketch axis"));
|
||||
}
|
||||
//add the base axes to the selection combo box
|
||||
ui->comboAxis->addItem(QString::fromAscii("Base X axis"));
|
||||
ui->comboAxis->addItem(QString::fromAscii("Base Y axis"));
|
||||
ui->comboAxis->addItem(QString::fromAscii("Base Z axis"));
|
||||
ui->comboAxis->addItem(QString::fromAscii("Select reference..."));
|
||||
if (!(sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())))
|
||||
sketch = 0;
|
||||
this->axesLinks.setCombo(*(ui->comboAxis));
|
||||
this->fillAxisCombo(axesLinks, static_cast<Part::Part2DObject*>(sketch));
|
||||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
|
@ -180,60 +176,16 @@ void TaskPolarPatternParameters::updateUI()
|
|||
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* axisFeature = pcPolarPattern->Axis.getValue();
|
||||
std::vector<std::string> axes = pcPolarPattern->Axis.getSubValues();
|
||||
bool reverse = pcPolarPattern->Reversed.getValue();
|
||||
double angle = pcPolarPattern->Angle.getValue();
|
||||
unsigned occurrences = pcPolarPattern->Occurrences.getValue();
|
||||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (sketch) {
|
||||
maxcount = 4;
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
if (axesLinks.setCurrentLink(pcPolarPattern->Axis) == -1){
|
||||
//failed to set current, because the link isnt in the list yet
|
||||
axesLinks.addLink(pcPolarPattern->Axis, getRefStr(pcPolarPattern->Axis.getValue(),pcPolarPattern->Axis.getSubValues()));
|
||||
axesLinks.setCurrentLink(pcPolarPattern->Axis);
|
||||
}
|
||||
|
||||
for (int i=ui->comboAxis->count()-1; i >= (sketch ? 4 : 3); i--)
|
||||
ui->comboAxis->removeItem(i);
|
||||
for (int i=ui->comboAxis->count(); i < maxcount; i++)
|
||||
ui->comboAxis->addItem(QString::fromAscii("Sketch axis %1").arg(i-1));
|
||||
|
||||
bool undefined = false;
|
||||
if (axisFeature != NULL && !axes.empty()) {
|
||||
bool is_base_line = axisFeature->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if (axes.front() == "N_Axis") {
|
||||
ui->comboAxis->setCurrentIndex(0);
|
||||
} else if (is_base_line && strcmp(static_cast<App::Line*>(axisFeature)->LineType.getValue(), App::Part::BaselineTypes[0]) == 0) {
|
||||
ui->comboAxis->setCurrentIndex((sketch ? 1 : 0));
|
||||
} else if (is_base_line && strcmp(static_cast<App::Line*>(axisFeature)->LineType.getValue(), App::Part::BaselineTypes[1]) == 0) {
|
||||
ui->comboAxis->setCurrentIndex((sketch ? 2 : 1));
|
||||
} else if (is_base_line && strcmp(static_cast<App::Line*>(axisFeature)->LineType.getValue(), App::Part::BaselineTypes[2]) == 0) {
|
||||
ui->comboAxis->setCurrentIndex((sketch ? 3 : 2));
|
||||
} else if (axes.front().size() > (sketch ? 4 : 3) && axes.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 4 : 3) + std::atoi(axes.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->comboAxis->setCurrentIndex(pos);
|
||||
else
|
||||
undefined = true;
|
||||
} else {
|
||||
ui->comboAxis->addItem(getRefStr(axisFeature, axes));
|
||||
ui->comboAxis->setCurrentIndex(maxcount);
|
||||
}
|
||||
} else {
|
||||
undefined = true;
|
||||
}
|
||||
|
||||
if (selectionMode == reference) {
|
||||
ui->comboAxis->addItem(tr("Select an edge or datum line"));
|
||||
ui->comboAxis->setCurrentIndex(ui->comboAxis->count() - 1);
|
||||
} else if (undefined) {
|
||||
ui->comboAxis->addItem(tr("Undefined"));
|
||||
ui->comboAxis->setCurrentIndex(ui->comboAxis->count() - 1);
|
||||
} else
|
||||
ui->comboAxis->addItem(tr("Select reference..."));
|
||||
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for blockUpdate
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
|
@ -266,32 +218,14 @@ void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges&
|
|||
} else if (selectionMode == reference) {
|
||||
// Note: ReferenceSelection has already checked the selection for validity
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
pcPolarPattern->Axis.setValue(selObj, axes);
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
pcPolarPattern->Axis.setValue(selObj, axes);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=1;
|
||||
if (sketch)
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
for (int i=ui->comboAxis->count()-1; i >= maxcount; i--)
|
||||
ui->comboAxis->removeItem(i);
|
||||
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
ui->comboAxis->addItem(getRefStr(selObj, axes));
|
||||
ui->comboAxis->setCurrentIndex(1);
|
||||
ui->comboAxis->addItem(tr("Select reference..."));
|
||||
}
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
|
||||
|
@ -349,50 +283,21 @@ void TaskPolarPatternParameters::onAxisChanged(int num) {
|
|||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* pcSketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (pcSketch) {
|
||||
maxcount = 4;
|
||||
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount();
|
||||
}
|
||||
|
||||
if(pcSketch) {
|
||||
if (num == 0) {
|
||||
pcPolarPattern->Axis.setValue(getSketchObject(), std::vector<std::string>(1,"N_Axis"));
|
||||
try{
|
||||
if(axesLinks.getCurrentLink().getValue() == 0){
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, false);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
pcPolarPattern->Axis.Paste(axesLinks.getCurrentLink());
|
||||
}
|
||||
} catch (Base::Exception &e) {
|
||||
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
|
||||
}
|
||||
if (num == (pcSketch ? 1 : 0)) {
|
||||
pcPolarPattern->Axis.setValue(getPartLines(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 2 : 1)) {
|
||||
pcPolarPattern->Axis.setValue(getPartLines(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 3 : 2)) {
|
||||
pcPolarPattern->Axis.setValue(getPartLines(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num >= (pcSketch ? 4 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(pcSketch ? 4 : 3));
|
||||
std::string str = buf.toStdString();
|
||||
pcPolarPattern->Axis.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == ui->comboAxis->count() - 1) {
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, false);
|
||||
}
|
||||
else if (num == maxcount)
|
||||
exitSelectionMode();
|
||||
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
@ -428,38 +333,9 @@ void TaskPolarPatternParameters::onFeatureDeleted(void)
|
|||
|
||||
void TaskPolarPatternParameters::getAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
{
|
||||
obj = getSketchObject();
|
||||
sub = std::vector<std::string>(1,"");
|
||||
int maxcount=1;
|
||||
if (obj) {
|
||||
maxcount = 4;
|
||||
maxcount += static_cast<Part::Part2DObject*>(obj)->getAxisCount();
|
||||
}
|
||||
|
||||
int num = ui->comboAxis->currentIndex();
|
||||
if(obj) {
|
||||
if (ui->comboAxis->currentIndex() == 0) {
|
||||
sub[0] = "N_Axis";
|
||||
}
|
||||
}
|
||||
if (num == (obj ? 1 : 0))
|
||||
obj = getPartLines(App::Part::BaselineTypes[0]);
|
||||
else if (num == (obj ? 2 : 1))
|
||||
obj = getPartLines(App::Part::BaselineTypes[1]);
|
||||
else if (num == (obj ? 3 : 2))
|
||||
obj = getPartLines(App::Part::BaselineTypes[2]);
|
||||
else if (num >= (obj ? 4 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(obj ? 4 : 3));
|
||||
sub[0] = buf.toStdString();
|
||||
}
|
||||
else if (num == maxcount && ui->comboAxis->count() == maxcount + 2) {
|
||||
QStringList parts = ui->comboAxis->currentText().split(QChar::fromAscii(':'));
|
||||
obj = getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
|
||||
if (parts.size() > 1)
|
||||
sub[0] = parts[1].toStdString();
|
||||
} else {
|
||||
obj = NULL;
|
||||
}
|
||||
const App::PropertyLinkSub &lnk = axesLinks.getCurrentLink();
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
|
||||
const bool TaskPolarPatternParameters::getReverse(void) const
|
||||
|
|
|
@ -86,6 +86,8 @@ private:
|
|||
private:
|
||||
Ui_TaskPolarPatternParameters* ui;
|
||||
QTimer* updateViewTimer;
|
||||
|
||||
ComboLinks axesLinks;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -118,57 +118,96 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol
|
|||
}
|
||||
}
|
||||
|
||||
void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
|
||||
{
|
||||
bool oldVal_blockUpdate = blockUpdate;
|
||||
blockUpdate = true;
|
||||
|
||||
if(axesInList.size() == 0)
|
||||
forceRefill = true;//not filled yet, full refill
|
||||
|
||||
if (forceRefill){
|
||||
ui->axis->clear();
|
||||
|
||||
for(int i = 0 ; i < axesInList.size() ; i++ ){
|
||||
delete axesInList[i];
|
||||
}
|
||||
this->axesInList.clear();
|
||||
|
||||
//add sketch axes
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
Part::Part2DObject* pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
if (pcSketch){
|
||||
addAxisToCombo(pcSketch,"V_Axis",QObject::tr("Vertical sketch axis"));
|
||||
addAxisToCombo(pcSketch,"H_Axis",QObject::tr("Horizontal sketch axis"));
|
||||
for (int i=0; i < pcSketch->getAxisCount(); i++) {
|
||||
QString itemText = QObject::tr("Construction line %1").arg(i+1);
|
||||
std::stringstream sub;
|
||||
sub << "Axis" << i;
|
||||
addAxisToCombo(pcSketch,sub.str(),itemText);
|
||||
}
|
||||
}
|
||||
|
||||
//add part axes
|
||||
App::DocumentObject* line = 0;
|
||||
line = getPartLines(App::Part::BaselineTypes[0]);
|
||||
if(line)
|
||||
addAxisToCombo(line,"",tr("Base X axis"));
|
||||
line = getPartLines(App::Part::BaselineTypes[1]);
|
||||
if(line)
|
||||
addAxisToCombo(line,"",tr("Base Y axis"));
|
||||
line = getPartLines(App::Part::BaselineTypes[2]);
|
||||
if(line)
|
||||
addAxisToCombo(line,"",tr("Base Z axis"));
|
||||
|
||||
//add "Select reference"
|
||||
addAxisToCombo(0,std::string(),tr("Select reference..."));
|
||||
}//endif forceRefill
|
||||
|
||||
//add current link, if not in list
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
//first, figure out the item number for current axis
|
||||
int indexOfCurrent = -1;
|
||||
App::DocumentObject* ax = pcRevolution->ReferenceAxis.getValue();
|
||||
const std::vector<std::string> &subList = pcRevolution->ReferenceAxis.getSubValues();
|
||||
for(int i = 0 ; i < axesInList.size() ; i++) {
|
||||
if(ax == axesInList[i]->getValue() && subList == axesInList[i]->getSubValues())
|
||||
indexOfCurrent = i;
|
||||
}
|
||||
if ( indexOfCurrent == -1 && ax ){
|
||||
const std::vector<std::string> &sublist = pcRevolution->ReferenceAxis.getSubValues();
|
||||
assert(sublist.size() <= 1);
|
||||
std::string sub;
|
||||
if (sublist.size()>0)
|
||||
sub = sublist[0];
|
||||
addAxisToCombo(ax, sub, getRefStr(ax, sublist));
|
||||
indexOfCurrent = axesInList.size()-1;
|
||||
}
|
||||
|
||||
//highlight current.
|
||||
if (indexOfCurrent != -1)
|
||||
ui->axis->setCurrentIndex(indexOfCurrent);
|
||||
|
||||
blockUpdate = oldVal_blockUpdate;
|
||||
}
|
||||
|
||||
void TaskRevolutionParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
||||
std::string linkSubname,
|
||||
QString itemText)
|
||||
{
|
||||
this->ui->axis->addItem(itemText);
|
||||
this->axesInList.push_back(new App::PropertyLinkSub());
|
||||
App::PropertyLinkSub &lnk = *(axesInList[axesInList.size()-1]);
|
||||
lnk.setValue(linkObj,std::vector<std::string>(1,linkSubname));
|
||||
}
|
||||
|
||||
void TaskRevolutionParameters::updateUI()
|
||||
{
|
||||
if (blockUpdate)
|
||||
return;
|
||||
blockUpdate = true;
|
||||
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
|
||||
App::DocumentObject* pcReferenceAxis = pcRevolution->ReferenceAxis.getValue();
|
||||
std::vector<std::string> sub = pcRevolution->ReferenceAxis.getSubValues();
|
||||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
int maxcount=5;
|
||||
if (pcSketch)
|
||||
maxcount += pcSketch->getAxisCount();
|
||||
|
||||
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) {
|
||||
bool is_base_line = pcReferenceAxis->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[0])==0)
|
||||
ui->axis->setCurrentIndex(0);
|
||||
else if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[1])==0)
|
||||
ui->axis->setCurrentIndex(1);
|
||||
else if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), 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
|
||||
undefined = true;
|
||||
} else {
|
||||
ui->axis->addItem(getRefStr(pcReferenceAxis, sub));
|
||||
ui->axis->setCurrentIndex(maxcount);
|
||||
}
|
||||
} else {
|
||||
undefined = true;
|
||||
}
|
||||
|
||||
ui->axis->addItem(tr("Select reference..."));
|
||||
fillAxisCombo();
|
||||
|
||||
blockUpdate = false;
|
||||
}
|
||||
|
@ -179,31 +218,13 @@ void TaskRevolutionParameters::onSelectionChanged(const Gui::SelectionChanges& m
|
|||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
std::vector<std::string> axis;
|
||||
App::DocumentObject* selObj;
|
||||
getReferencedSelection(pcRevolution, msg, selObj, axis);
|
||||
pcRevolution->ReferenceAxis.setValue(selObj, axis);
|
||||
std::vector<std::string> axis;
|
||||
App::DocumentObject* selObj;
|
||||
getReferencedSelection(pcRevolution, msg, selObj, axis);
|
||||
pcRevolution->ReferenceAxis.setValue(selObj, axis);
|
||||
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
int maxcount=5;
|
||||
if (pcSketch)
|
||||
maxcount += pcSketch->getAxisCount();
|
||||
for (int i=ui->axis->count()-1; i >= maxcount; i--)
|
||||
ui->axis->removeItem(i);
|
||||
|
||||
std::vector<std::string> sub;
|
||||
App::DocumentObject* selObj;
|
||||
getReferencedSelection(pcRevolution, msg, selObj, sub);
|
||||
ui->axis->addItem(getRefStr(selObj, sub));
|
||||
ui->axis->setCurrentIndex(maxcount);
|
||||
ui->axis->addItem(tr("Select reference..."));
|
||||
}
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,37 +242,27 @@ void TaskRevolutionParameters::onAxisChanged(int num)
|
|||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
|
||||
if(axesInList.size() == 0)
|
||||
return;
|
||||
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
if (pcSketch) {
|
||||
App::DocumentObject *oldRefAxis = pcRevolution->ReferenceAxis.getValue();
|
||||
std::vector<std::string> oldSubRefAxis = pcRevolution->ReferenceAxis.getSubValues();
|
||||
|
||||
int maxcount = pcSketch->getAxisCount()+5;
|
||||
if (num == 0) {
|
||||
pcRevolution->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[0]), std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcRevolution->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[1]), std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 2) {
|
||||
pcRevolution->ReferenceAxis.setValue(getPartLines(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 == 4) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,"V_Axis"));
|
||||
exitSelectionMode();
|
||||
} 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));
|
||||
exitSelectionMode();
|
||||
} else if (num == ui->axis->count() - 1) {
|
||||
App::PropertyLinkSub &lnk = *(axesInList[num]);
|
||||
if(lnk.getValue() == 0){
|
||||
// enter reference selection mode
|
||||
TaskSketchBasedParameters::onSelectReference(true, true, false, true);
|
||||
} else if (num == maxcount)
|
||||
} else {
|
||||
if (! pcRevolution->getDocument()->isIn(lnk.getValue())){
|
||||
Base::Console().Error("Object was deleted\n");
|
||||
return;
|
||||
}
|
||||
pcRevolution->ReferenceAxis.Paste(lnk);
|
||||
exitSelectionMode();
|
||||
}
|
||||
|
||||
App::DocumentObject *newRefAxis = pcRevolution->ReferenceAxis.getValue();
|
||||
const std::vector<std::string> &newSubRefAxis = pcRevolution->ReferenceAxis.getSubValues();
|
||||
|
@ -293,40 +304,22 @@ double TaskRevolutionParameters::getAngle(void) const
|
|||
|
||||
void TaskRevolutionParameters::getReferenceAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
{
|
||||
// get the support and Sketch
|
||||
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=5;
|
||||
if (obj)
|
||||
maxcount += static_cast<Part::Part2DObject*>(obj)->getAxisCount();
|
||||
if (axesInList.size() == 0)
|
||||
throw Base::Exception("Not initialized!");
|
||||
|
||||
if (obj) {
|
||||
int num = ui->axis->currentIndex();
|
||||
if(num == 0)
|
||||
obj = getPartLines(App::Part::BaselineTypes[0]);
|
||||
else if(num == 1)
|
||||
obj = getPartLines(App::Part::BaselineTypes[1]);
|
||||
else if(num == 2)
|
||||
obj = getPartLines(App::Part::BaselineTypes[2]);
|
||||
else if (num == 3)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 4)
|
||||
sub[0] = "V_Axis";
|
||||
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) {
|
||||
QStringList parts = ui->axis->currentText().split(QChar::fromAscii(':'));
|
||||
obj = vp->getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
|
||||
if (parts.size() > 1)
|
||||
sub[0] = parts[1].toStdString();
|
||||
} else {
|
||||
obj = NULL;
|
||||
int num = ui->axis->currentIndex();
|
||||
const App::PropertyLinkSub &lnk = *(axesInList[num]);
|
||||
if(lnk.getValue() == 0){
|
||||
throw Base::Exception("Still in reference selection mode; reference wasn't selected yet");
|
||||
} else {
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
if (! pcRevolution->getDocument()->isIn(lnk.getValue())){
|
||||
throw Base::Exception("Object was deleted");
|
||||
return;
|
||||
}
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
else
|
||||
obj = NULL;
|
||||
}
|
||||
|
||||
bool TaskRevolutionParameters::getMidplane(void) const
|
||||
|
@ -353,6 +346,10 @@ TaskRevolutionParameters::~TaskRevolutionParameters()
|
|||
}
|
||||
|
||||
delete ui;
|
||||
|
||||
for(int i = 0 ; i < axesInList.size() ; i++ ){
|
||||
delete axesInList[i];
|
||||
}
|
||||
}
|
||||
|
||||
void TaskRevolutionParameters::changeEvent(QEvent *e)
|
||||
|
|
|
@ -55,6 +55,15 @@ public:
|
|||
|
||||
void apply();
|
||||
|
||||
/**
|
||||
* @brief fillAxisCombo fills the combo and selects the item according to
|
||||
* current value of revolution object's axis reference.
|
||||
* @param forceRefill if true, the combo box will be completely refilled. If
|
||||
* false, the current value of revolution object's axis will be added to the
|
||||
* list (if necessary), and selected. If the list is empty, it will be refilled anyway.
|
||||
*/
|
||||
void fillAxisCombo(bool forceRefill = false);
|
||||
void addAxisToCombo(App::DocumentObject *linkObj, std::string linkSubname, QString itemText);
|
||||
private Q_SLOTS:
|
||||
void onAngleChanged(double);
|
||||
void onAxisChanged(int);
|
||||
|
@ -76,6 +85,16 @@ private:
|
|||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskRevolutionParameters* ui;
|
||||
|
||||
/**
|
||||
* @brief axesInList is the list of links corresponding to axis combo; must
|
||||
* be kept in sync with the combo. A special value of zero-pointer link is
|
||||
* for "Select axis" item.
|
||||
*
|
||||
* It is a list of pointers, because properties prohibit assignment. Use new
|
||||
* when adding stuff, and delete when removing stuff.
|
||||
*/
|
||||
std::vector<App::PropertyLinkSub*> axesInList;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
|
|
|
@ -184,16 +184,17 @@ App::DocumentObject* TaskTransformedParameters::getPartPlanes(const char* str) c
|
|||
App::DocumentObject* obj = getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
|
||||
for(App::DocumentObject* plane : planes) {
|
||||
|
||||
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
|
||||
return plane;
|
||||
if (part) {
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
|
||||
for(App::DocumentObject* plane : planes) {
|
||||
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
|
||||
return plane;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -204,23 +205,92 @@ App::DocumentObject* TaskTransformedParameters::getPartLines(const char* str) co
|
|||
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
|
||||
for(App::DocumentObject* line : lines) {
|
||||
|
||||
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
|
||||
return line;
|
||||
App::Part* part = getPartFor(obj, false);
|
||||
if (part) {
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
|
||||
for(App::DocumentObject* line : lines) {
|
||||
|
||||
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::fillAxisCombo(ComboLinks &combolinks,
|
||||
Part::Part2DObject* sketch)
|
||||
{
|
||||
combolinks.clear();
|
||||
|
||||
//add sketch axes
|
||||
if (sketch){
|
||||
combolinks.addLink(sketch, "N_Axis",tr("Normal sketch axis"));
|
||||
combolinks.addLink(sketch,"V_Axis",tr("Vertical sketch axis"));
|
||||
combolinks.addLink(sketch,"H_Axis",tr("Horizontal sketch axis"));
|
||||
for (int i=0; i < sketch->getAxisCount(); i++) {
|
||||
QString itemText = tr("Construction line %1").arg(i+1);
|
||||
std::stringstream sub;
|
||||
sub << "Axis" << i;
|
||||
combolinks.addLink(sketch,sub.str(),itemText);
|
||||
}
|
||||
}
|
||||
|
||||
//add part axes
|
||||
App::DocumentObject* line = 0;
|
||||
line = getPartLines(App::Part::BaselineTypes[0]);
|
||||
if(line)
|
||||
combolinks.addLink(line,"",tr("Base X axis"));
|
||||
line = getPartLines(App::Part::BaselineTypes[1]);
|
||||
if(line)
|
||||
combolinks.addLink(line,"",tr("Base Y axis"));
|
||||
line = getPartLines(App::Part::BaselineTypes[2]);
|
||||
if(line)
|
||||
combolinks.addLink(line,"",tr("Base Z axis"));
|
||||
|
||||
//add "Select reference"
|
||||
combolinks.addLink(0,std::string(),tr("Select reference..."));
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::fillPlanesCombo(ComboLinks &combolinks,
|
||||
Part::Part2DObject* sketch)
|
||||
{
|
||||
combolinks.clear();
|
||||
|
||||
//add sketch axes
|
||||
if (sketch){
|
||||
combolinks.addLink(sketch,"V_Axis",QObject::tr("Vertical sketch axis"));
|
||||
combolinks.addLink(sketch,"H_Axis",QObject::tr("Horizontal sketch axis"));
|
||||
for (int i=0; i < sketch->getAxisCount(); i++) {
|
||||
QString itemText = tr("Construction line %1").arg(i+1);
|
||||
std::stringstream sub;
|
||||
sub << "Axis" << i;
|
||||
combolinks.addLink(sketch,sub.str(),itemText);
|
||||
}
|
||||
}
|
||||
|
||||
//add part baseplanes
|
||||
App::DocumentObject* plane = 0;
|
||||
plane = getPartPlanes(App::Part::BaseplaneTypes[0]);
|
||||
if(plane)
|
||||
combolinks.addLink(plane,"",tr("Base XY plane"));
|
||||
plane = getPartPlanes(App::Part::BaseplaneTypes[1]);
|
||||
if(plane)
|
||||
combolinks.addLink(plane,"",tr("Base XZ plane"));
|
||||
plane = getPartPlanes(App::Part::BaseplaneTypes[2]);
|
||||
if(plane)
|
||||
combolinks.addLink(plane,"",tr("Base YZ plane"));
|
||||
|
||||
//add "Select reference"
|
||||
combolinks.addLink(0,std::string(),tr("Select reference..."));
|
||||
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::recomputeFeature()
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
|
@ -403,3 +473,76 @@ bool TaskDlgTransformedParameters::reject()
|
|||
|
||||
|
||||
#include "moc_TaskTransformedParameters.cpp"
|
||||
|
||||
|
||||
ComboLinks::ComboLinks(QComboBox &combo)
|
||||
: doc(0)
|
||||
{
|
||||
this->_combo = &combo;
|
||||
_combo->clear();
|
||||
}
|
||||
|
||||
int ComboLinks::addLink(const App::PropertyLinkSub &lnk, QString itemText)
|
||||
{
|
||||
if(!_combo)
|
||||
return 0;
|
||||
_combo->addItem(itemText);
|
||||
this->linksInList.push_back(new App::PropertyLinkSub());
|
||||
App::PropertyLinkSub &newitem = *(linksInList[linksInList.size()-1]);
|
||||
newitem.Paste(lnk);
|
||||
if (newitem.getValue() && this->doc == 0)
|
||||
this->doc = newitem.getValue()->getDocument();
|
||||
return linksInList.size()-1;
|
||||
}
|
||||
|
||||
int ComboLinks::addLink(App::DocumentObject *linkObj, std::string linkSubname, QString itemText)
|
||||
{
|
||||
if(!_combo)
|
||||
return 0;
|
||||
_combo->addItem(itemText);
|
||||
this->linksInList.push_back(new App::PropertyLinkSub());
|
||||
App::PropertyLinkSub &newitem = *(linksInList[linksInList.size()-1]);
|
||||
newitem.setValue(linkObj,std::vector<std::string>(1,linkSubname));
|
||||
if (newitem.getValue() && this->doc == 0)
|
||||
this->doc = newitem.getValue()->getDocument();
|
||||
return linksInList.size()-1;
|
||||
}
|
||||
|
||||
void ComboLinks::clear()
|
||||
{
|
||||
for(int i = 0 ; i < this->linksInList.size() ; i++){
|
||||
delete linksInList[i];
|
||||
}
|
||||
if(this->_combo)
|
||||
_combo->clear();
|
||||
}
|
||||
|
||||
App::PropertyLinkSub &ComboLinks::getLink(int index) const
|
||||
{
|
||||
if (index < 0 || index > linksInList.size()-1)
|
||||
throw Base::Exception("ComboLinks::getLink:Index out of range");
|
||||
if (linksInList[index]->getValue() && doc && !(doc->isIn(linksInList[index]->getValue())))
|
||||
throw Base::Exception("Linked object is not in the document; it may have been deleted");
|
||||
return *(linksInList[index]);
|
||||
}
|
||||
|
||||
App::PropertyLinkSub &ComboLinks::getCurrentLink() const
|
||||
{
|
||||
assert(_combo);
|
||||
return getLink(_combo->currentIndex());
|
||||
}
|
||||
|
||||
int ComboLinks::setCurrentLink(const App::PropertyLinkSub &lnk)
|
||||
{
|
||||
for(int i = 0 ; i < linksInList.size() ; i++) {
|
||||
App::PropertyLinkSub &it = *(linksInList[i]);
|
||||
if(lnk.getValue() == it.getValue() && lnk.getSubValues() == it.getSubValues()){
|
||||
bool wasBlocked = _combo->signalsBlocked();
|
||||
_combo->blockSignals(true);
|
||||
_combo->setCurrentIndex(i);
|
||||
_combo->blockSignals(wasBlocked);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
#ifndef GUI_TASKVIEW_TaskTransformedParameters_H
|
||||
#define GUI_TASKVIEW_TaskTransformedParameters_H
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
@ -41,6 +45,63 @@ namespace PartDesignGui {
|
|||
|
||||
class TaskMultiTransformParameters;
|
||||
|
||||
/**
|
||||
* @brief The ComboLinks class is a helper class that binds to a combo box and
|
||||
* provides an interface to add links, retrieve links and select items by link
|
||||
* value
|
||||
*/
|
||||
class ComboLinks
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief ComboLinks constructor.
|
||||
* @param combo. It will be cleared as soon as it is bound. Don't add or
|
||||
* remove items from the combo directly, otherwise internal tracking list
|
||||
* will go out of sync, and crashes may result.
|
||||
*/
|
||||
ComboLinks(QComboBox &combo);
|
||||
ComboLinks() {_combo = 0; doc = 0;};
|
||||
void setCombo(QComboBox &combo) {assert(_combo == 0); this->_combo = &combo; _combo->clear();}
|
||||
|
||||
/**
|
||||
* @brief addLink adds an item to the combo. Doesn't check for duplicates.
|
||||
* @param lnk can be a link to NULL, which is usually used for special item "Select Reference"
|
||||
* @param itemText
|
||||
* @return
|
||||
*/
|
||||
int addLink(const App::PropertyLinkSub &lnk, QString itemText);
|
||||
int addLink(App::DocumentObject* linkObj, std::string linkSubname, QString itemText);
|
||||
void clear();
|
||||
App::PropertyLinkSub& getLink(int index) const;
|
||||
|
||||
/**
|
||||
* @brief getCurrentLink
|
||||
* @return the link corresponding to the selected item. May be null link,
|
||||
* which is usually used to indicate a "Select reference..." special item.
|
||||
* Otherwise, the link is automatically tested for validity (oif an object
|
||||
* doesn't exist in the document, an exception will be thrown.)
|
||||
*/
|
||||
App::PropertyLinkSub& getCurrentLink() const;
|
||||
|
||||
/**
|
||||
* @brief setCurrentLink selects the item with the link that matches the
|
||||
* argument. If there is no such link in the list, -1 is returned and
|
||||
* selected item is not changed. Signals from combo are blocked in this
|
||||
* function.
|
||||
* @param lnk
|
||||
* @return the index of an item that was selected, -1 if link is not in the list yet.
|
||||
*/
|
||||
int setCurrentLink(const App::PropertyLinkSub &lnk);
|
||||
|
||||
QComboBox& combo(void) const {assert(_combo); return *_combo;};
|
||||
|
||||
~ComboLinks() {_combo = 0; clear();};
|
||||
private:
|
||||
QComboBox* _combo;
|
||||
App::Document* doc;
|
||||
std::vector<App::PropertyLinkSub*> linksInList;
|
||||
};
|
||||
|
||||
/**
|
||||
The transformed subclasses will be used in two different modes:
|
||||
1. As a stand-alone feature
|
||||
|
@ -105,6 +166,9 @@ protected:
|
|||
App::DocumentObject* getPartPlanes(const char* str) const;
|
||||
App::DocumentObject* getPartLines(const char* str) const;
|
||||
|
||||
void fillAxisCombo(ComboLinks &combolinks, Part::Part2DObject *sketch);
|
||||
void fillPlanesCombo(ComboLinks &combolinks, Part2DObject *sketch);
|
||||
|
||||
protected:
|
||||
QWidget* proxy;
|
||||
ViewProviderTransformed *TransformedView;
|
||||
|
|
Loading…
Reference in New Issue
Block a user