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:
DeepSOIC 2015-07-19 23:19:16 +03:00 committed by Stefan Tröger
parent 2625233dff
commit 9776d30b87
12 changed files with 661 additions and 882 deletions

View File

@ -153,19 +153,14 @@ void TaskLinearPatternParameters::setupUI()
ui->spinLength->blockSignals(false); ui->spinLength->blockSignals(false);
ui->spinOccurrences->setEnabled(true); ui->spinOccurrences->setEnabled(true);
dirLinks.setCombo(*(ui->comboDirection));
App::DocumentObject* sketch = getSketchObject(); App::DocumentObject* sketch = getSketchObject();
if (sketch) { if (!sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
ui->comboDirection->addItem(QString::fromAscii("Horizontal sketch axis")); sketch = 0;
ui->comboDirection->addItem(QString::fromAscii("Vertical sketch axis")); this->fillAxisCombo(dirLinks,static_cast<Part::Part2DObject*>(sketch));
}
//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..."));
updateUI(); updateUI();
//show the parts coordinate system axis for selection //show the parts coordinate system axis for selection
App::Part* part = getPartFor(getObject(), false); App::Part* part = getPartFor(getObject(), false);
if(part) { if(part) {
@ -176,7 +171,7 @@ void TaskLinearPatternParameters::setupUI()
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument()); origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
origin->setTemporaryVisibilityAxis(true); origin->setTemporaryVisibilityAxis(true);
} }
} }
} }
void TaskLinearPatternParameters::updateUI() void TaskLinearPatternParameters::updateUI()
@ -187,62 +182,16 @@ void TaskLinearPatternParameters::updateUI()
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject()); 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(); bool reverse = pcLinearPattern->Reversed.getValue();
double length = pcLinearPattern->Length.getValue(); double length = pcLinearPattern->Length.getValue();
unsigned occurrences = pcLinearPattern->Occurrences.getValue(); unsigned occurrences = pcLinearPattern->Occurrences.getValue();
// Add user-defined sketch axes to the reference selection combo box if (dirLinks.setCurrentLink(pcLinearPattern->Direction) == -1){
App::DocumentObject* sketch = getSketchObject(); //failed to set current, because the link isnt in the list yet
int maxcount=3; dirLinks.addLink(pcLinearPattern->Direction, getRefStr(pcLinearPattern->Direction.getValue(),pcLinearPattern->Direction.getSubValues()));
if (sketch) { dirLinks.setCurrentLink(pcLinearPattern->Direction);
maxcount = 5;
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
} }
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 // Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
// didn't check for blockUpdate // didn't check for blockUpdate
ui->checkReverse->setChecked(reverse); ui->checkReverse->setChecked(reverse);
@ -275,32 +224,14 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
} else if (selectionMode == reference) { } else if (selectionMode == reference) {
// Note: ReferenceSelection has already checked the selection for validity // Note: ReferenceSelection has already checked the selection for validity
exitSelectionMode(); exitSelectionMode();
if (!blockUpdate) { std::vector<std::string> directions;
std::vector<std::string> directions; App::DocumentObject* selObj;
App::DocumentObject* selObj; PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject()); getReferencedSelection(pcLinearPattern, msg, selObj, directions);
getReferencedSelection(pcLinearPattern, msg, selObj, directions); pcLinearPattern->Direction.setValue(selObj, directions);
pcLinearPattern->Direction.setValue(selObj, directions);
recomputeFeature(); recomputeFeature();
updateUI(); 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..."));
}
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr || } else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr || strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) { strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
@ -357,55 +288,21 @@ void TaskLinearPatternParameters::onDirectionChanged(int num) {
if (blockUpdate) if (blockUpdate)
return; return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject()); PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
try{
App::DocumentObject* pcSketch = getSketchObject(); if(dirLinks.getCurrentLink().getValue() == 0){
int maxcount=3; // enter reference selection mode
if (pcSketch) { hideObject();
maxcount = 5; showBase();
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount(); selectionMode = reference;
} Gui::Selection().clearSelection();
addReferenceSelectionGate(true, true);
if(pcSketch) { } else {
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"));
exitSelectionMode(); 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(); kickUpdateViewTimer();
} }
@ -441,38 +338,9 @@ void TaskLinearPatternParameters::onFeatureDeleted(void)
void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::vector<std::string>& sub) const void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::vector<std::string>& sub) const
{ {
obj = getSketchObject(); const App::PropertyLinkSub &lnk = dirLinks.getCurrentLink();
sub = std::vector<std::string>(1,""); obj = lnk.getValue();
int maxcount=3; sub = lnk.getSubValues();
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 bool TaskLinearPatternParameters::getReverse(void) const const bool TaskLinearPatternParameters::getReverse(void) const

View File

@ -36,6 +36,9 @@
#include <Base/UnitsApi.h> #include <Base/UnitsApi.h>
#include <App/Application.h> #include <App/Application.h>
#include <App/Document.h> #include <App/Document.h>
#include <App/Part.h>
#include <App/Origin.h>
#include <App/Line.h>
#include <Gui/Application.h> #include <Gui/Application.h>
#include <Gui/Document.h> #include <Gui/Document.h>
#include <Gui/BitmapFactory.h> #include <Gui/BitmapFactory.h>
@ -44,6 +47,7 @@
#include <Base/Console.h> #include <Base/Console.h>
#include <Gui/Selection.h> #include <Gui/Selection.h>
#include <Gui/Command.h> #include <Gui/Command.h>
#include <Gui/ViewProviderOrigin.h>
#include <Mod/PartDesign/App/FeatureLinearPattern.h> #include <Mod/PartDesign/App/FeatureLinearPattern.h>
#include <Mod/PartDesign/App/DatumPlane.h> #include <Mod/PartDesign/App/DatumPlane.h>
#include <Mod/PartDesign/App/DatumLine.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) for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i)
{ {
if ((*i) != NULL) if ((*i) != NULL)
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
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
} }
// --------------------- // ---------------------
@ -152,7 +152,26 @@ void TaskLinearPatternParameters::setupUI()
ui->spinLength->setUnit(Base::Unit::Length); ui->spinLength->setUnit(Base::Unit::Length);
ui->spinLength->blockSignals(false); ui->spinLength->blockSignals(false);
ui->spinOccurrences->setEnabled(true); 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(); 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() void TaskLinearPatternParameters::updateUI()
@ -163,37 +182,38 @@ void TaskLinearPatternParameters::updateUI()
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject()); 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(); bool reverse = pcLinearPattern->Reversed.getValue();
double length = pcLinearPattern->Length.getValue(); double length = pcLinearPattern->Length.getValue();
unsigned occurrences = pcLinearPattern->Occurrences.getValue(); unsigned occurrences = pcLinearPattern->Occurrences.getValue();
// Add user-defined sketch axes to the reference selection combo box if (dirLinks.setCurrentLink(pcLinearPattern->Direction) == -1){
App::DocumentObject* sketch = getSketchObject(); //failed to set current, because the link isnt in the list yet
int maxcount=5; dirLinks.addLink(pcLinearPattern->Direction, getRefStr(pcLinearPattern->Direction.getValue(),pcLinearPattern->Direction.getSubValues()));
if (sketch) dirLinks.setCurrentLink(pcLinearPattern->Direction);
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount(); }
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); ui->comboDirection->removeItem(i);
for (int i=ui->comboDirection->count(); i < maxcount; i++) for (int i=ui->comboDirection->count(); i < maxcount; i++)
ui->comboDirection->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5)); ui->comboDirection->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
bool undefined = false; bool undefined = false;
if (directionFeature != NULL && !directions.empty()) { if (directionFeature != NULL && !directions.empty()) {
bool is_base_line = directionFeature->isDerivedFrom(App::Line::getClassTypeId());
if (directions.front() == "H_Axis") if (directions.front() == "H_Axis")
ui->comboDirection->setCurrentIndex(0); ui->comboDirection->setCurrentIndex(0);
else if (directions.front() == "V_Axis") else if (directions.front() == "V_Axis")
ui->comboDirection->setCurrentIndex(1); ui->comboDirection->setCurrentIndex(1);
else if (strcmp(directionFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[0]) == 0) else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
ui->comboDirection->setCurrentIndex(2); ui->comboDirection->setCurrentIndex( sketch ? 2 : 0);
else if (strcmp(directionFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[1]) == 0) else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
ui->comboDirection->setCurrentIndex(3); ui->comboDirection->setCurrentIndex(sketch ? 3 : 1);
else if (strcmp(directionFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[2]) == 0) else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
ui->comboDirection->setCurrentIndex(4); ui->comboDirection->setCurrentIndex(sketch ? 4 : 2);
else if (directions.front().size() > 4 && directions.front().substr(0,4) == "Axis") { else if (directions.front().size() > (sketch ? 4 : 2) && directions.front().substr(0,4) == "Axis") {
int pos = 5 + std::atoi(directions.front().substr(4,4000).c_str()); int pos = (sketch ? 5 : 3) + std::atoi(directions.front().substr(4,4000).c_str());
if (pos <= maxcount) if (pos <= maxcount)
ui->comboDirection->setCurrentIndex(pos); ui->comboDirection->setCurrentIndex(pos);
else else
@ -215,6 +235,8 @@ void TaskLinearPatternParameters::updateUI()
} else } else
ui->comboDirection->addItem(tr("Select reference...")); 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 // Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
// didn't check for blockUpdate // didn't check for blockUpdate
ui->checkReverse->setChecked(reverse); ui->checkReverse->setChecked(reverse);
@ -239,11 +261,7 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
if (msg.Type == Gui::SelectionChanges::AddSelection) { if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (originalSelected(msg)) { if (originalSelected(msg)) {
if (selectionMode == addFeature) if (selectionMode == addFeature)
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName));
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
else else
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName); removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
@ -251,32 +269,26 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
} else if (selectionMode == reference) { } else if (selectionMode == reference) {
// Note: ReferenceSelection has already checked the selection for validity // Note: ReferenceSelection has already checked the selection for validity
exitSelectionMode(); exitSelectionMode();
if (!blockUpdate) { std::vector<std::string> directions;
std::vector<std::string> directions; App::DocumentObject* selObj;
App::DocumentObject* selObj; PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject()); getReferencedSelection(pcLinearPattern, msg, selObj, directions);
getReferencedSelection(pcLinearPattern, msg, selObj, directions); pcLinearPattern->Direction.setValue(selObj, directions);
pcLinearPattern->Direction.setValue(selObj, directions);
recomputeFeature(); recomputeFeature();
updateUI(); updateUI();
} } else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
else { strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
App::DocumentObject* sketch = getSketchObject(); strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
int maxcount=5;
if (sketch) std::vector<std::string> directions;
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount(); App::DocumentObject* selObj;
for (int i=ui->comboDirection->count()-1; i >= maxcount; i--) PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
ui->comboDirection->removeItem(i); getReferencedSelection(pcLinearPattern, msg, selObj, directions);
pcLinearPattern->Direction.setValue(selObj, directions);
std::vector<std::string> directions; recomputeFeature();
App::DocumentObject* selObj; updateUI();
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..."));
}
} }
} }
} }
@ -321,51 +333,21 @@ void TaskLinearPatternParameters::onDirectionChanged(int num) {
if (blockUpdate) if (blockUpdate)
return; return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject()); PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
try{
App::DocumentObject* pcSketch = getSketchObject(); if(dirLinks.getCurrentLink().getValue() == 0){
int maxcount=5; // enter reference selection mode
if (pcSketch) hideObject();
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount(); showBase();
selectionMode = reference;
if (num == 0) { Gui::Selection().clearSelection();
pcLinearPattern->Direction.setValue(pcSketch, std::vector<std::string>(1,"H_Axis")); addReferenceSelectionGate(true, true);
exitSelectionMode(); } 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(); kickUpdateViewTimer();
} }
@ -401,34 +383,9 @@ void TaskLinearPatternParameters::onFeatureDeleted(void)
void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::vector<std::string>& sub) const void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::vector<std::string>& sub) const
{ {
obj = getSketchObject(); const App::PropertyLinkSub &lnk = dirLinks.getCurrentLink();
sub = std::vector<std::string>(1,""); obj = lnk.getValue();
int maxcount=5; sub = lnk.getSubValues();
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 bool TaskLinearPatternParameters::getReverse(void) const const bool TaskLinearPatternParameters::getReverse(void) const
@ -449,6 +406,17 @@ const unsigned TaskLinearPatternParameters::getOccurrences(void) const
TaskLinearPatternParameters::~TaskLinearPatternParameters() 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; delete ui;
if (proxy) if (proxy)
delete proxy; delete proxy;
@ -470,10 +438,11 @@ void TaskLinearPatternParameters::apply()
App::DocumentObject* obj; App::DocumentObject* obj;
getDirection(obj, directions); getDirection(obj, directions);
std::string direction = getPythonStr(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()); 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.Direction = None", name.c_str());
}
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),getReverse()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),getReverse());
ui->spinLength->apply(); ui->spinLength->apply();

View File

@ -85,6 +85,8 @@ private:
private: private:
Ui_TaskLinearPatternParameters* ui; Ui_TaskLinearPatternParameters* ui;
QTimer* updateViewTimer; QTimer* updateViewTimer;
ComboLinks dirLinks;
}; };

View File

@ -125,18 +125,15 @@ void TaskMirroredParameters::setupUI()
} }
// --------------------- // ---------------------
this->planeLinks.setCombo(*(ui->comboPlane));
ui->comboPlane->setEnabled(true); ui->comboPlane->setEnabled(true);
App::DocumentObject* sketch = getSketchObject(); App::DocumentObject* sketch = getSketchObject();
if (sketch) { if (!sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
ui->comboPlane->addItem(QString::fromAscii("Horizontal sketch axis")); sketch = 0;
ui->comboPlane->addItem(QString::fromAscii("Vertical sketch axis")); this->fillPlanesCombo(planeLinks,static_cast<Part::Part2DObject*>(sketch));
}
//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..."));
updateUI(); updateUI();
//show the parts coordinate system axis for selection //show the parts coordinate system axis for selection
@ -160,59 +157,12 @@ void TaskMirroredParameters::updateUI()
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject()); PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue(); if (planeLinks.setCurrentLink(pcMirrored->MirrorPlane) == -1){
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues(); //failed to set current, because the link isnt in the list yet
planeLinks.addLink(pcMirrored->MirrorPlane, getRefStr(pcMirrored->MirrorPlane.getValue(),pcMirrored->MirrorPlane.getSubValues()));
// Add user-defined sketch axes to the reference selection combo box planeLinks.setCurrentLink(pcMirrored->MirrorPlane);
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 >= (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; blockUpdate = false;
} }
@ -229,34 +179,15 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
} else if (selectionMode == reference) { } else if (selectionMode == reference) {
// Note: ReferenceSelection has already checked the selection for validity // Note: ReferenceSelection has already checked the selection for validity
exitSelectionMode(); 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(); std::vector<std::string> mirrorPlanes;
updateUI(); App::DocumentObject* selObj;
} PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
else { getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
App::DocumentObject* sketch = getSketchObject(); pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
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; recomputeFeature();
App::DocumentObject* selObj; updateUI();
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..."));
}
} else if( strstr(msg.pObjectName, App::Part::BaseplaneTypes[0]) == nullptr || } else if( strstr(msg.pObjectName, App::Part::BaseplaneTypes[0]) == nullptr ||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[1]) == nullptr || strstr(msg.pObjectName, App::Part::BaseplaneTypes[1]) == nullptr ||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[2]) == nullptr) { strstr(msg.pObjectName, App::Part::BaseplaneTypes[2]) == nullptr) {
@ -283,55 +214,21 @@ void TaskMirroredParameters::onPlaneChanged(int num) {
if (blockUpdate) if (blockUpdate)
return; return;
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject()); PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
try{
App::DocumentObject* pcSketch = getSketchObject(); if(planeLinks.getCurrentLink().getValue() == 0){
int maxcount=3; // enter reference selection mode
if (pcSketch) { hideObject();
maxcount = 5; showBase();
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount(); selectionMode = reference;
} Gui::Selection().clearSelection();
addReferenceSelectionGate(false, true);
if(pcSketch) { } else {
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"));
exitSelectionMode(); 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(); recomputeFeature();
} }
@ -362,40 +259,11 @@ void TaskMirroredParameters::onFeatureDeleted(void)
recomputeFeature(); 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(); const App::PropertyLinkSub &lnk = planeLinks.getCurrentLink();
sub = std::vector<std::string>(1,""); obj = lnk.getValue();
int maxcount=3; sub = lnk.getSubValues();
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;
}
} }
void TaskMirroredParameters::apply() void TaskMirroredParameters::apply()

View File

@ -34,6 +34,8 @@
#include "ReferenceSelection.h" #include "ReferenceSelection.h"
#include <App/Application.h> #include <App/Application.h>
#include <App/Document.h> #include <App/Document.h>
#include <App/Part.h>
#include <App/Plane.h>
#include <Gui/Application.h> #include <Gui/Application.h>
#include <Gui/Document.h> #include <Gui/Document.h>
#include <Gui/BitmapFactory.h> #include <Gui/BitmapFactory.h>
@ -42,6 +44,7 @@
#include <Base/Console.h> #include <Base/Console.h>
#include <Gui/Selection.h> #include <Gui/Selection.h>
#include <Gui/Command.h> #include <Gui/Command.h>
#include <Gui/ViewProviderOrigin.h>
#include <Mod/PartDesign/App/DatumPlane.h> #include <Mod/PartDesign/App/DatumPlane.h>
#include <Mod/PartDesign/App/FeatureMirrored.h> #include <Mod/PartDesign/App/FeatureMirrored.h>
#include <Mod/Sketcher/App/SketchObject.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) for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i)
{ {
if ((*i) != NULL) if ((*i) != NULL)
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
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
} }
// --------------------- // ---------------------
this->planeLinks.setCombo(*(ui->comboPlane));
ui->comboPlane->setEnabled(true); 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(); 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() void TaskMirroredParameters::updateUI()
@ -138,34 +157,39 @@ void TaskMirroredParameters::updateUI()
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject()); PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
<<<<<<< 05d084614fa15ead10b7283f4f36e3e587279953
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue(); App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues(); std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
// Add user-defined sketch axes to the reference selection combo box // Add user-defined sketch axes to the reference selection combo box
App::DocumentObject* sketch = getSketchObject(); App::DocumentObject* sketch = getSketchObject();
int maxcount=5; int maxcount=3;
if (sketch) if (sketch) {
maxcount = 5;
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount(); 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); ui->comboPlane->removeItem(i);
for (int i=ui->comboPlane->count(); i < maxcount; i++) for (int i=ui->comboPlane->count(); i < maxcount; i++)
ui->comboPlane->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5)); ui->comboPlane->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
bool undefined = false; bool undefined = false;
if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) { if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
bool is_base_plane = mirrorPlaneFeature->isDerivedFrom(App::Plane::getClassTypeId());
if (mirrorPlanes.front() == "H_Axis") if (mirrorPlanes.front() == "H_Axis")
ui->comboPlane->setCurrentIndex(0); ui->comboPlane->setCurrentIndex(0);
else if (mirrorPlanes.front() == "V_Axis") else if (mirrorPlanes.front() == "V_Axis")
ui->comboPlane->setCurrentIndex(1); ui->comboPlane->setCurrentIndex(1);
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[0]) == 0) else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
ui->comboPlane->setCurrentIndex(2); ui->comboPlane->setCurrentIndex((sketch ? 2 : 0));
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[1]) == 0) else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
ui->comboPlane->setCurrentIndex(3); ui->comboPlane->setCurrentIndex((sketch ? 3 : 1));
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), PartDesignGui::BaseplaneNames[2]) == 0) else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
ui->comboPlane->setCurrentIndex(4); ui->comboPlane->setCurrentIndex((sketch ? 4 : 2));
else if (mirrorPlanes.front().size() > 4 && mirrorPlanes.front().substr(0,4) == "Axis") { else if (mirrorPlanes.front().size() > (sketch ? 4 : 2) && mirrorPlanes.front().substr(0,4) == "Axis") {
int pos = 5 + std::atoi(mirrorPlanes.front().substr(4,4000).c_str()); int pos = (sketch ? 5 : 3) + std::atoi(mirrorPlanes.front().substr(4,4000).c_str());
if (pos <= maxcount) if (pos <= maxcount)
ui->comboPlane->setCurrentIndex(pos); ui->comboPlane->setCurrentIndex(pos);
else else
@ -176,17 +200,14 @@ void TaskMirroredParameters::updateUI()
} }
} else { } else {
undefined = true; 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; blockUpdate = false;
} }
@ -196,43 +217,34 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
if (originalSelected(msg)) { if (originalSelected(msg)) {
if (selectionMode == addFeature) if (selectionMode == addFeature)
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName));
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
else else
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName); removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
exitSelectionMode(); exitSelectionMode();
} else if (selectionMode == reference) { } else if (selectionMode == reference) {
// Note: ReferenceSelection has already checked the selection for validity // Note: ReferenceSelection has already checked the selection for validity
exitSelectionMode(); 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(); std::vector<std::string> mirrorPlanes;
updateUI(); App::DocumentObject* selObj;
} PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
else { getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
App::DocumentObject* sketch = getSketchObject(); pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
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; recomputeFeature();
App::DocumentObject* selObj; updateUI();
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject()); } else if( strstr(msg.pObjectName, App::Part::BaseplaneTypes[0]) == nullptr ||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes); strstr(msg.pObjectName, App::Part::BaseplaneTypes[1]) == nullptr ||
ui->comboPlane->addItem(getRefStr(selObj, mirrorPlanes)); strstr(msg.pObjectName, App::Part::BaseplaneTypes[2]) == nullptr) {
ui->comboPlane->setCurrentIndex(maxcount);
ui->comboPlane->addItem(tr("Select reference...")); 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) if (blockUpdate)
return; return;
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject()); PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
try{
App::DocumentObject* pcSketch = getSketchObject(); if(planeLinks.getCurrentLink().getValue() == 0){
int maxcount=5; // enter reference selection mode
if (pcSketch) hideObject();
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount(); showBase();
selectionMode = reference;
if (num == 0) { Gui::Selection().clearSelection();
pcMirrored->MirrorPlane.setValue(pcSketch, std::vector<std::string>(1,"H_Axis")); addReferenceSelectionGate(false, true);
exitSelectionMode(); } 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(); recomputeFeature();
} }
@ -322,36 +304,11 @@ void TaskMirroredParameters::onFeatureDeleted(void)
recomputeFeature(); 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(); const App::PropertyLinkSub &lnk = planeLinks.getCurrentLink();
sub = std::vector<std::string>(1,""); obj = lnk.getValue();
int maxcount=5; sub = lnk.getSubValues();
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;
}
} }
void TaskMirroredParameters::apply() void TaskMirroredParameters::apply()
@ -360,6 +317,18 @@ void TaskMirroredParameters::apply()
TaskMirroredParameters::~TaskMirroredParameters() 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; delete ui;
if (proxy) if (proxy)
delete proxy; delete proxy;
@ -401,10 +370,11 @@ bool TaskDlgMirroredParameters::accept()
App::DocumentObject* obj; App::DocumentObject* obj;
mirrorParameter->getMirrorPlane(obj, mirrorPlanes); mirrorParameter->getMirrorPlane(obj, mirrorPlanes);
std::string mirrorPlane = getPythonStr(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()); 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.%s.MirrorPlane = None", name.c_str());
}
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!TransformedView->getObject()->isValid()) if (!TransformedView->getObject()->isValid())
throw Base::Exception(TransformedView->getObject()->getStatusString()); throw Base::Exception(TransformedView->getObject()->getStatusString());

View File

@ -74,6 +74,7 @@ protected:
private: private:
void setupUI(); void setupUI();
void updateUI(); void updateUI();
ComboLinks planeLinks;
private: private:
Ui_TaskMirroredParameters* ui; Ui_TaskMirroredParameters* ui;

View File

@ -149,14 +149,10 @@ void TaskPolarPatternParameters::setupUI()
ui->spinOccurrences->setEnabled(true); ui->spinOccurrences->setEnabled(true);
App::DocumentObject* sketch = getSketchObject(); App::DocumentObject* sketch = getSketchObject();
if (sketch) { if (!(sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())))
ui->comboAxis->addItem(QString::fromAscii("Normal sketch axis")); sketch = 0;
} this->axesLinks.setCombo(*(ui->comboAxis));
//add the base axes to the selection combo box this->fillAxisCombo(axesLinks, static_cast<Part::Part2DObject*>(sketch));
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..."));
updateUI(); updateUI();
//show the parts coordinate system axis for selection //show the parts coordinate system axis for selection
@ -180,60 +176,16 @@ void TaskPolarPatternParameters::updateUI()
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject()); 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(); bool reverse = pcPolarPattern->Reversed.getValue();
double angle = pcPolarPattern->Angle.getValue(); double angle = pcPolarPattern->Angle.getValue();
unsigned occurrences = pcPolarPattern->Occurrences.getValue(); unsigned occurrences = pcPolarPattern->Occurrences.getValue();
// Add user-defined sketch axes to the reference selection combo box if (axesLinks.setCurrentLink(pcPolarPattern->Axis) == -1){
App::DocumentObject* sketch = getSketchObject(); //failed to set current, because the link isnt in the list yet
int maxcount=3; axesLinks.addLink(pcPolarPattern->Axis, getRefStr(pcPolarPattern->Axis.getValue(),pcPolarPattern->Axis.getSubValues()));
if (sketch) { axesLinks.setCurrentLink(pcPolarPattern->Axis);
maxcount = 4;
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
} }
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 // Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
// didn't check for blockUpdate // didn't check for blockUpdate
ui->checkReverse->setChecked(reverse); ui->checkReverse->setChecked(reverse);
@ -266,32 +218,14 @@ void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges&
} else if (selectionMode == reference) { } else if (selectionMode == reference) {
// Note: ReferenceSelection has already checked the selection for validity // Note: ReferenceSelection has already checked the selection for validity
exitSelectionMode(); exitSelectionMode();
if (!blockUpdate) { std::vector<std::string> axes;
std::vector<std::string> axes; App::DocumentObject* selObj;
App::DocumentObject* selObj; PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject()); getReferencedSelection(pcPolarPattern, msg, selObj, axes);
getReferencedSelection(pcPolarPattern, msg, selObj, axes); pcPolarPattern->Axis.setValue(selObj, axes);
pcPolarPattern->Axis.setValue(selObj, axes);
recomputeFeature(); recomputeFeature();
updateUI(); 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..."));
}
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr || } else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr || strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) { strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
@ -349,50 +283,21 @@ void TaskPolarPatternParameters::onAxisChanged(int num) {
return; return;
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject()); PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
App::DocumentObject* pcSketch = getSketchObject(); try{
int maxcount=3; if(axesLinks.getCurrentLink().getValue() == 0){
if (pcSketch) { // enter reference selection mode
maxcount = 4; hideObject();
maxcount += static_cast<Part::Part2DObject*>(pcSketch)->getAxisCount(); showBase();
} selectionMode = reference;
Gui::Selection().clearSelection();
if(pcSketch) { addReferenceSelectionGate(true, false);
if (num == 0) { } else {
pcPolarPattern->Axis.setValue(getSketchObject(), std::vector<std::string>(1,"N_Axis"));
exitSelectionMode(); 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(); kickUpdateViewTimer();
} }
@ -428,38 +333,9 @@ void TaskPolarPatternParameters::onFeatureDeleted(void)
void TaskPolarPatternParameters::getAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const void TaskPolarPatternParameters::getAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const
{ {
obj = getSketchObject(); const App::PropertyLinkSub &lnk = axesLinks.getCurrentLink();
sub = std::vector<std::string>(1,""); obj = lnk.getValue();
int maxcount=1; sub = lnk.getSubValues();
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 bool TaskPolarPatternParameters::getReverse(void) const const bool TaskPolarPatternParameters::getReverse(void) const

View File

@ -86,6 +86,8 @@ private:
private: private:
Ui_TaskPolarPatternParameters* ui; Ui_TaskPolarPatternParameters* ui;
QTimer* updateViewTimer; QTimer* updateViewTimer;
ComboLinks axesLinks;
}; };

View File

@ -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() void TaskRevolutionParameters::updateUI()
{ {
if (blockUpdate) if (blockUpdate)
return; return;
blockUpdate = true; blockUpdate = true;
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject()); fillAxisCombo();
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..."));
blockUpdate = false; blockUpdate = false;
} }
@ -179,31 +218,13 @@ void TaskRevolutionParameters::onSelectionChanged(const Gui::SelectionChanges& m
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject()); PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
exitSelectionMode(); exitSelectionMode();
if (!blockUpdate) { std::vector<std::string> axis;
std::vector<std::string> axis; App::DocumentObject* selObj;
App::DocumentObject* selObj; getReferencedSelection(pcRevolution, msg, selObj, axis);
getReferencedSelection(pcRevolution, msg, selObj, axis); pcRevolution->ReferenceAxis.setValue(selObj, axis);
pcRevolution->ReferenceAxis.setValue(selObj, axis);
recomputeFeature();
recomputeFeature(); updateUI();
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..."));
}
} }
} }
@ -221,37 +242,27 @@ void TaskRevolutionParameters::onAxisChanged(int num)
if (blockUpdate) if (blockUpdate)
return; return;
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject()); PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
if(axesInList.size() == 0)
return;
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue()); Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
if (pcSketch) { if (pcSketch) {
App::DocumentObject *oldRefAxis = pcRevolution->ReferenceAxis.getValue(); App::DocumentObject *oldRefAxis = pcRevolution->ReferenceAxis.getValue();
std::vector<std::string> oldSubRefAxis = pcRevolution->ReferenceAxis.getSubValues(); std::vector<std::string> oldSubRefAxis = pcRevolution->ReferenceAxis.getSubValues();
int maxcount = pcSketch->getAxisCount()+5; App::PropertyLinkSub &lnk = *(axesInList[num]);
if (num == 0) { if(lnk.getValue() == 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) {
// enter reference selection mode // enter reference selection mode
TaskSketchBasedParameters::onSelectReference(true, true, false, true); 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(); exitSelectionMode();
}
App::DocumentObject *newRefAxis = pcRevolution->ReferenceAxis.getValue(); App::DocumentObject *newRefAxis = pcRevolution->ReferenceAxis.getValue();
const std::vector<std::string> &newSubRefAxis = pcRevolution->ReferenceAxis.getSubValues(); 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 void TaskRevolutionParameters::getReferenceAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const
{ {
// get the support and Sketch if (axesInList.size() == 0)
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject()); throw Base::Exception("Not initialized!");
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 (obj) { int num = ui->axis->currentIndex();
int num = ui->axis->currentIndex(); const App::PropertyLinkSub &lnk = *(axesInList[num]);
if(num == 0) if(lnk.getValue() == 0){
obj = getPartLines(App::Part::BaselineTypes[0]); throw Base::Exception("Still in reference selection mode; reference wasn't selected yet");
else if(num == 1) } else {
obj = getPartLines(App::Part::BaselineTypes[1]); PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
else if(num == 2) if (! pcRevolution->getDocument()->isIn(lnk.getValue())){
obj = getPartLines(App::Part::BaselineTypes[2]); throw Base::Exception("Object was deleted");
else if (num == 3) return;
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;
} }
obj = lnk.getValue();
sub = lnk.getSubValues();
} }
else
obj = NULL;
} }
bool TaskRevolutionParameters::getMidplane(void) const bool TaskRevolutionParameters::getMidplane(void) const
@ -353,6 +346,10 @@ TaskRevolutionParameters::~TaskRevolutionParameters()
} }
delete ui; delete ui;
for(int i = 0 ; i < axesInList.size() ; i++ ){
delete axesInList[i];
}
} }
void TaskRevolutionParameters::changeEvent(QEvent *e) void TaskRevolutionParameters::changeEvent(QEvent *e)

View File

@ -55,6 +55,15 @@ public:
void apply(); 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: private Q_SLOTS:
void onAngleChanged(double); void onAngleChanged(double);
void onAxisChanged(int); void onAxisChanged(int);
@ -76,6 +85,16 @@ private:
private: private:
QWidget* proxy; QWidget* proxy;
Ui_TaskRevolutionParameters* ui; 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 /// simulation dialog for the TaskView

View File

@ -184,16 +184,17 @@ App::DocumentObject* TaskTransformedParameters::getPartPlanes(const char* str) c
App::DocumentObject* obj = getObject(); App::DocumentObject* obj = getObject();
App::Part* part = getPartFor(obj, true); App::Part* part = getPartFor(obj, true);
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId()); if (part) {
if(origs.size()<1) std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
return nullptr; if(origs.size()<1)
return nullptr;
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId()); App::Origin* orig = static_cast<App::Origin*>(origs[0]);
for(App::DocumentObject* plane : planes) { auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
for(App::DocumentObject* plane : planes) {
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0) if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
return plane; return plane;
}
} }
return nullptr; return nullptr;
@ -204,23 +205,92 @@ App::DocumentObject* TaskTransformedParameters::getPartLines(const char* str) co
//TODO: Adjust to GRAPH handling when available //TODO: Adjust to GRAPH handling when available
App::DocumentObject* obj = getObject(); App::DocumentObject* obj = getObject();
App::Part* part = getPartFor(obj, true); App::Part* part = getPartFor(obj, false);
if (part) {
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId()); std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
if(origs.size()<1) if(origs.size()<1)
return nullptr; return nullptr;
App::Origin* orig = static_cast<App::Origin*>(origs[0]); App::Origin* orig = static_cast<App::Origin*>(origs[0]);
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId()); auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
for(App::DocumentObject* line : lines) { for(App::DocumentObject* line : lines) {
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0) if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
return line; return line;
}
} }
return nullptr; 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() void TaskTransformedParameters::recomputeFeature()
{ {
if (insideMultiTransform) { if (insideMultiTransform) {
@ -403,3 +473,76 @@ bool TaskDlgTransformedParameters::reject()
#include "moc_TaskTransformedParameters.cpp" #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;
}

View File

@ -24,6 +24,10 @@
#ifndef GUI_TASKVIEW_TaskTransformedParameters_H #ifndef GUI_TASKVIEW_TaskTransformedParameters_H
#define GUI_TASKVIEW_TaskTransformedParameters_H #define GUI_TASKVIEW_TaskTransformedParameters_H
#include <QComboBox>
#include <Mod/Part/App/Part2DObject.h>
#include <Gui/TaskView/TaskView.h> #include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h> #include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h> #include <Gui/TaskView/TaskDialog.h>
@ -41,6 +45,63 @@ namespace PartDesignGui {
class TaskMultiTransformParameters; 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: The transformed subclasses will be used in two different modes:
1. As a stand-alone feature 1. As a stand-alone feature
@ -105,6 +166,9 @@ protected:
App::DocumentObject* getPartPlanes(const char* str) const; App::DocumentObject* getPartPlanes(const char* str) const;
App::DocumentObject* getPartLines(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: protected:
QWidget* proxy; QWidget* proxy;
ViewProviderTransformed *TransformedView; ViewProviderTransformed *TransformedView;