PartDesign: restrict patterns to only one original and improve selection of references
This commit is contained in:
parent
afc794894f
commit
8b35efdb83
|
@ -716,23 +716,24 @@ CmdPartDesignMirrored::CmdPartDesignMirrored()
|
|||
|
||||
void CmdPartDesignMirrored::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1 ||
|
||||
(!selection[0].isObjectTypeOf(PartDesign::Additive::getClassTypeId()) &&
|
||||
!selection[0].isObjectTypeOf(PartDesign::Subtractive::getClassTypeId()))) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
QObject::tr("Select only one additive or subtractive feature, please."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Mirrored");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){
|
||||
str << "App.activeDocument()." << it->getFeatName() << ",";
|
||||
tempSelNames.push_back(it->getFeatName());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -755,9 +756,7 @@ void CmdPartDesignMirrored::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignMirrored::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -779,23 +778,24 @@ CmdPartDesignLinearPattern::CmdPartDesignLinearPattern()
|
|||
|
||||
void CmdPartDesignLinearPattern::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1 ||
|
||||
(!selection[0].isObjectTypeOf(PartDesign::Additive::getClassTypeId()) &&
|
||||
!selection[0].isObjectTypeOf(PartDesign::Subtractive::getClassTypeId()))) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
QObject::tr("Select only one additive or subtractive feature, please."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("LinearPattern");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){
|
||||
str << "App.activeDocument()." << it->getFeatName() << ",";
|
||||
tempSelNames.push_back(it->getFeatName());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -818,9 +818,7 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignLinearPattern::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -842,23 +840,24 @@ CmdPartDesignPolarPattern::CmdPartDesignPolarPattern()
|
|||
|
||||
void CmdPartDesignPolarPattern::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1 ||
|
||||
(!selection[0].isObjectTypeOf(PartDesign::Additive::getClassTypeId()) &&
|
||||
!selection[0].isObjectTypeOf(PartDesign::Subtractive::getClassTypeId()))) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
QObject::tr("Select only one additive or subtractive feature, please."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("PolarPattern");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){
|
||||
str << "App.activeDocument()." << it->getFeatName() << ",";
|
||||
tempSelNames.push_back(it->getFeatName());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -881,9 +880,7 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignPolarPattern::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -905,23 +902,24 @@ CmdPartDesignScaled::CmdPartDesignScaled()
|
|||
|
||||
void CmdPartDesignScaled::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1 ||
|
||||
(!selection[0].isObjectTypeOf(PartDesign::Additive::getClassTypeId()) &&
|
||||
!selection[0].isObjectTypeOf(PartDesign::Subtractive::getClassTypeId()))) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
QObject::tr("Select only one additive or subtractive feature, please."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Scaled");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){
|
||||
str << "App.activeDocument()." << it->getFeatName() << ",";
|
||||
tempSelNames.push_back(it->getFeatName());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -943,9 +941,7 @@ void CmdPartDesignScaled::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignScaled::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -967,23 +963,24 @@ CmdPartDesignMultiTransform::CmdPartDesignMultiTransform()
|
|||
|
||||
void CmdPartDesignMultiTransform::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1 ||
|
||||
(!selection[0].isObjectTypeOf(PartDesign::Additive::getClassTypeId()) &&
|
||||
!selection[0].isObjectTypeOf(PartDesign::Subtractive::getClassTypeId()))) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
QObject::tr("Select only one additive or subtractive feature, please."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("MultiTransform");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){
|
||||
str << "App.activeDocument()." << it->getFeatName() << ",";
|
||||
tempSelNames.push_back(it->getFeatName());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -1001,9 +998,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignMultiTransform::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(ViewProviderTransformed
|
|||
ui->buttonOK->hide();
|
||||
ui->checkBoxUpdateView->setEnabled(true);
|
||||
|
||||
referenceSelectionMode = false;
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
@ -79,9 +81,12 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParam
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
referenceSelectionMode = false;
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
@ -100,35 +105,24 @@ void TaskLinearPatternParameters::setupUI()
|
|||
this, SLOT(onLength(double)));
|
||||
connect(ui->spinOccurrences, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(onOccurrences(int)));
|
||||
connect(ui->buttonReference, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonReference()));
|
||||
connect(ui->buttonReference, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonReference(bool)));
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskLinearPatternParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcLinearPattern->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->buttonX->setEnabled(true);
|
||||
|
@ -144,8 +138,10 @@ void TaskLinearPatternParameters::setupUI()
|
|||
|
||||
void TaskLinearPatternParameters::updateUI()
|
||||
{
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
updateUIinProgress = true;
|
||||
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* directionFeature = pcLinearPattern->Direction.getValue();
|
||||
|
@ -155,9 +151,9 @@ void TaskLinearPatternParameters::updateUI()
|
|||
double length = pcLinearPattern->Length.getValue();
|
||||
unsigned occurrences = pcLinearPattern->Occurrences.getValue();
|
||||
|
||||
if ((featureSelectionMode || insideMultiTransform) && !stdDirection.empty())
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
if (!stdDirection.empty())
|
||||
{
|
||||
ui->buttonReference->setDown(false);
|
||||
ui->buttonX->setAutoExclusive(true);
|
||||
ui->buttonY->setAutoExclusive(true);
|
||||
ui->buttonZ->setAutoExclusive(true);
|
||||
|
@ -165,19 +161,20 @@ void TaskLinearPatternParameters::updateUI()
|
|||
ui->buttonY->setChecked(stdDirection == "Y");
|
||||
ui->buttonZ->setChecked(stdDirection == "Z");
|
||||
ui->lineReference->setText(tr(""));
|
||||
} else if ((directionFeature != NULL) && !directions.empty()) {
|
||||
} else if (directionFeature != NULL && !directions.empty()) {
|
||||
ui->buttonX->setAutoExclusive(false);
|
||||
ui->buttonY->setAutoExclusive(false);
|
||||
ui->buttonZ->setAutoExclusive(false);
|
||||
ui->buttonX->setChecked(false);
|
||||
ui->buttonY->setChecked(false);
|
||||
ui->buttonZ->setChecked(false);
|
||||
ui->buttonReference->setDown(!featureSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(directions.front().c_str()));
|
||||
} else {
|
||||
// Error message?
|
||||
ui->lineReference->setText(tr(""));
|
||||
}
|
||||
if (referenceSelectionMode)
|
||||
ui->lineReference->setText(tr("Select an edge or a face"));
|
||||
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for updateUIinProgress
|
||||
|
@ -190,55 +187,33 @@ void TaskLinearPatternParameters::updateUI()
|
|||
|
||||
void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
App::DocumentObject* selectedObject = pcLinearPattern->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
return;
|
||||
|
||||
std::string element(msg.pSubName);
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
// TODO
|
||||
// if (originalElementName == "") {
|
||||
// Base::Console().Error("Element created by this pattern cannot be used for direction\n");
|
||||
// return;
|
||||
// }
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
std::string subName(msg.pSubName);
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
if (originalSelectionMode) {
|
||||
App::DocumentObject* selectedObject = pcLinearPattern->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
if (originalSelected(msg))
|
||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else if (referenceSelectionMode &&
|
||||
((subName.size() > 4 && subName.substr(0,4) == "Edge") ||
|
||||
(subName.size() > 4 && subName.substr(0,4) == "Face"))) {
|
||||
|
||||
std::vector<std::string> directions;
|
||||
directions.push_back(element.c_str());
|
||||
directions.push_back(subName.c_str());
|
||||
pcLinearPattern->Direction.setValue(getOriginalObject(), directions);
|
||||
pcLinearPattern->StdDirection.setValue("");
|
||||
|
||||
if (insideMultiTransform) {
|
||||
if (parentTask->updateView())
|
||||
recomputeFeature();
|
||||
} else
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true; // Jump back to selection of originals
|
||||
|
||||
showObject();
|
||||
hideOriginals();
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onButtonX() {
|
||||
onStdDirection("X");
|
||||
}
|
||||
|
@ -252,55 +227,66 @@ void TaskLinearPatternParameters::onButtonZ() {
|
|||
}
|
||||
|
||||
void TaskLinearPatternParameters::onCheckReverse(const bool on) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->Reversed.setValue(on);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onLength(const double l) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->Length.setValue(l);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onOccurrences(const int n) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->Occurrences.setValue(n);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onStdDirection(const std::string& dir) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->StdDirection.setValue(dir.c_str());
|
||||
pcLinearPattern->Direction.setValue(NULL);
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true;
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onButtonReference()
|
||||
void TaskLinearPatternParameters::onButtonReference(bool checked)
|
||||
{
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->StdDirection.setValue("");
|
||||
featureSelectionMode = false;
|
||||
hideObject();
|
||||
showOriginals();
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
if (checked ) {
|
||||
hideObject();
|
||||
showOriginals();
|
||||
referenceSelectionMode = true;
|
||||
Gui::Selection().clearSelection();
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
@ -309,7 +295,6 @@ void TaskLinearPatternParameters::onUpdateView(bool on)
|
|||
ui->buttonX->blockSignals(!on);
|
||||
ui->buttonY->blockSignals(!on);
|
||||
ui->buttonZ->blockSignals(!on);
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
ui->checkReverse->blockSignals(!on);
|
||||
ui->spinLength->blockSignals(!on);
|
||||
ui->spinOccurrences->blockSignals(!on);
|
||||
|
@ -352,18 +337,38 @@ const QString TaskLinearPatternParameters::getDirection(void) const
|
|||
return buf;
|
||||
}
|
||||
|
||||
const bool TaskLinearPatternParameters::getReverse(void) const {
|
||||
const bool TaskLinearPatternParameters::getReverse(void) const
|
||||
{
|
||||
return ui->checkReverse->isChecked();
|
||||
}
|
||||
|
||||
const double TaskLinearPatternParameters::getLength(void) const {
|
||||
const double TaskLinearPatternParameters::getLength(void) const
|
||||
{
|
||||
return ui->spinLength->value();
|
||||
}
|
||||
|
||||
const unsigned TaskLinearPatternParameters::getOccurrences(void) const {
|
||||
const unsigned TaskLinearPatternParameters::getOccurrences(void) const
|
||||
{
|
||||
return ui->spinOccurrences->value();
|
||||
}
|
||||
|
||||
const bool TaskLinearPatternParameters::updateView() const
|
||||
{
|
||||
if (insideMultiTransform)
|
||||
return parentTask->updateView();
|
||||
else
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::exitSelectionMode()
|
||||
{
|
||||
originalSelectionMode = false;
|
||||
referenceSelectionMode = false;
|
||||
showObject();
|
||||
hideOriginals();
|
||||
}
|
||||
|
||||
|
||||
TaskLinearPatternParameters::~TaskLinearPatternParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Gui {
|
|||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
namespace PartDesignGui {
|
||||
|
||||
class TaskMultiTransformParameters;
|
||||
|
||||
|
@ -61,6 +61,7 @@ public:
|
|||
const bool getReverse(void) const;
|
||||
const double getLength(void) const;
|
||||
const unsigned getOccurrences(void) const;
|
||||
const bool updateView() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onStdDirection(const std::string& dir);
|
||||
|
@ -70,17 +71,19 @@ private Q_SLOTS:
|
|||
void onCheckReverse(const bool on);
|
||||
void onLength(const double l);
|
||||
void onOccurrences(const int n);
|
||||
virtual void onButtonReference();
|
||||
virtual void onOriginalDeleted();
|
||||
void onButtonReference(const bool checked);
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
bool referenceSelectionMode;
|
||||
|
||||
private:
|
||||
void updateUI();
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
void exitSelectionMode();
|
||||
|
||||
private:
|
||||
Ui_TaskLinearPatternParameters* ui;
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
|
@ -52,6 +63,9 @@
|
|||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -132,6 +146,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -57,11 +57,14 @@ TaskMirroredParameters::TaskMirroredParameters(ViewProviderTransformed *Transfor
|
|||
ui = new Ui_TaskMirroredParameters();
|
||||
ui->setupUi(proxy);
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->hide();
|
||||
ui->checkBoxUpdateView->setEnabled(true);
|
||||
|
||||
referenceSelectionMode = false;
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
@ -79,9 +82,12 @@ TaskMirroredParameters::TaskMirroredParameters(TaskMultiTransformParameters *par
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
referenceSelectionMode = false;
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
@ -94,35 +100,24 @@ void TaskMirroredParameters::setupUI()
|
|||
this, SLOT(onButtonXZ()));
|
||||
connect(ui->buttonYZ, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonYZ()));
|
||||
connect(ui->buttonReference, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonReference()));
|
||||
connect(ui->buttonReference, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonReference(bool)));
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskMirroredParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcMirrored->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->buttonXY->setEnabled(true);
|
||||
|
@ -130,22 +125,22 @@ void TaskMirroredParameters::setupUI()
|
|||
ui->buttonYZ->setEnabled(true);
|
||||
ui->buttonReference->setEnabled(true);
|
||||
ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::updateUI()
|
||||
{
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
updateUIinProgress = true;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
|
||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
||||
std::string stdMirrorPlane = pcMirrored->StdMirrorPlane.getValue();
|
||||
|
||||
if ((featureSelectionMode || insideMultiTransform) && !stdMirrorPlane.empty())
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
if (!stdMirrorPlane.empty())
|
||||
{
|
||||
ui->buttonReference->setDown(false);
|
||||
ui->buttonXY->setAutoExclusive(true);
|
||||
ui->buttonXZ->setAutoExclusive(true);
|
||||
ui->buttonYZ->setAutoExclusive(true);
|
||||
|
@ -153,82 +148,63 @@ void TaskMirroredParameters::updateUI()
|
|||
ui->buttonXZ->setChecked(stdMirrorPlane == "XZ");
|
||||
ui->buttonYZ->setChecked(stdMirrorPlane == "YZ");
|
||||
ui->lineReference->setText(tr(""));
|
||||
} else if ((mirrorPlaneFeature != NULL) && !mirrorPlanes.empty()) {
|
||||
} else if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
|
||||
ui->buttonXY->setAutoExclusive(false);
|
||||
ui->buttonXZ->setAutoExclusive(false);
|
||||
ui->buttonYZ->setAutoExclusive(false);
|
||||
ui->buttonXY->setChecked(false);
|
||||
ui->buttonXZ->setChecked(false);
|
||||
ui->buttonYZ->setChecked(false);
|
||||
ui->buttonReference->setDown(!featureSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(mirrorPlanes.front().c_str()));
|
||||
} else {
|
||||
// Error message?
|
||||
ui->lineReference->setText(tr(""));
|
||||
}
|
||||
if (referenceSelectionMode)
|
||||
ui->lineReference->setText(tr("Select a plane"));
|
||||
|
||||
updateUIinProgress = false;
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
App::DocumentObject* selectedObject = pcMirrored->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
return;
|
||||
|
||||
std::string element(msg.pSubName);
|
||||
|
||||
if (element.substr(0,4) != "Face")
|
||||
return;
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
std::string subName(msg.pSubName);
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
if (originalSelectionMode) {
|
||||
App::DocumentObject* selectedObject = pcMirrored->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
if (originalSelected(msg))
|
||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else if (referenceSelectionMode &&
|
||||
(subName.size() > 4 && subName.substr(0,4) == "Face")) {
|
||||
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
mirrorPlanes.push_back(element.c_str());
|
||||
mirrorPlanes.push_back(subName.c_str());
|
||||
pcMirrored->MirrorPlane.setValue(getOriginalObject(), mirrorPlanes);
|
||||
pcMirrored->StdMirrorPlane.setValue("");
|
||||
|
||||
if (insideMultiTransform) {
|
||||
if (parentTask->updateView())
|
||||
recomputeFeature();
|
||||
} else
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true; // Jump back to selection of originals
|
||||
|
||||
showObject();
|
||||
hideOriginals();
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onStdMirrorPlane(const std::string &plane) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
pcMirrored->StdMirrorPlane.setValue(plane.c_str());
|
||||
pcMirrored->MirrorPlane.setValue(NULL);
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true;
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onButtonXY() {
|
||||
|
@ -243,13 +219,18 @@ void TaskMirroredParameters::onButtonYZ() {
|
|||
onStdMirrorPlane("YZ");
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onButtonReference()
|
||||
void TaskMirroredParameters::onButtonReference(bool checked)
|
||||
{
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
pcMirrored->StdMirrorPlane.setValue("");
|
||||
featureSelectionMode = false;
|
||||
hideObject();
|
||||
showOriginals();
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
if (checked ) {
|
||||
hideObject();
|
||||
showOriginals();
|
||||
referenceSelectionMode = true;
|
||||
Gui::Selection().clearSelection();
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
@ -258,7 +239,6 @@ void TaskMirroredParameters::onUpdateView(bool on)
|
|||
ui->buttonXY->blockSignals(!on);
|
||||
ui->buttonYZ->blockSignals(!on);
|
||||
ui->buttonXZ->blockSignals(!on);
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
}
|
||||
|
||||
const std::string TaskMirroredParameters::getStdMirrorPlane(void) const
|
||||
|
@ -298,6 +278,23 @@ const QString TaskMirroredParameters::getMirrorPlane(void) const
|
|||
return buf;
|
||||
}
|
||||
|
||||
const bool TaskMirroredParameters::updateView() const
|
||||
{
|
||||
if (insideMultiTransform)
|
||||
return parentTask->updateView();
|
||||
else
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::exitSelectionMode()
|
||||
{
|
||||
originalSelectionMode = false;
|
||||
referenceSelectionMode = false;
|
||||
showObject();
|
||||
hideOriginals();
|
||||
}
|
||||
|
||||
|
||||
TaskMirroredParameters::~TaskMirroredParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Gui {
|
|||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
namespace PartDesignGui {
|
||||
|
||||
class TaskMultiTransformParameters;
|
||||
|
||||
|
@ -59,23 +59,26 @@ public:
|
|||
|
||||
const QString getMirrorPlane(void) const;
|
||||
const std::string getStdMirrorPlane(void) const;
|
||||
const bool updateView() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onButtonXY();
|
||||
void onButtonXZ();
|
||||
void onButtonYZ();
|
||||
virtual void onButtonReference();
|
||||
virtual void onOriginalDeleted();
|
||||
void onButtonReference(const bool checked);
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
bool referenceSelectionMode;
|
||||
|
||||
private:
|
||||
void onStdMirrorPlane(const std::string& plane);
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
void exitSelectionMode();
|
||||
|
||||
private:
|
||||
Ui_TaskMirroredParameters* ui;
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
|
@ -52,6 +63,9 @@
|
|||
<property name="text">
|
||||
<string>Plane</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -80,6 +94,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -68,35 +68,35 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
|||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
// Create a context menu for the listview of transformation features
|
||||
QAction* action = new QAction(tr("Edit"), ui->listFeatures);
|
||||
QAction* action = new QAction(tr("Edit"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformEdit()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action = new QAction(tr("Delete"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformDelete()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add mirrored transformation"), ui->listFeatures);
|
||||
action = new QAction(tr("Add mirrored transformation"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddMirrored()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add linear pattern"), ui->listFeatures);
|
||||
action = new QAction(tr("Add linear pattern"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddLinearPattern()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add polar pattern"), ui->listFeatures);
|
||||
action = new QAction(tr("Add polar pattern"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddPolarPattern()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add scaled transformation"), ui->listFeatures);
|
||||
action = new QAction(tr("Add scaled transformation"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddScaled()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Move up"), ui->listFeatures);
|
||||
action = new QAction(tr("Move up"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onMoveUp()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Move down"), ui->listFeatures);
|
||||
action = new QAction(tr("Move down"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onMoveDown()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
|
@ -127,29 +127,18 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
|||
editHint = true;
|
||||
}
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskMultiTransformParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the Originals data
|
||||
std::vector<App::DocumentObject*> originals = pcMultiTransform->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false); // This is never enabled since it is for optical feed-back only
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
}
|
||||
|
||||
|
@ -160,12 +149,9 @@ void TaskMultiTransformParameters::onSelectionChanged(const Gui::SelectionChange
|
|||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
// There is no reference that could be selected... must be an error to arrive here at all!
|
||||
featureSelectionMode = true;
|
||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +170,7 @@ void TaskMultiTransformParameters::onTransformDelete()
|
|||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
|
||||
App::DocumentObject* feature = *(transformFeatures.begin() + row);
|
||||
App::DocumentObject* feature = transformFeatures[row];
|
||||
pcMultiTransform->getDocument()->remObject(feature->getNameInDocument());
|
||||
closeSubTask();
|
||||
|
||||
|
@ -331,7 +317,7 @@ void TaskMultiTransformParameters::moveTransformFeature(const int increment)
|
|||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
|
||||
App::DocumentObject* feature = *(transformFeatures.begin() + row);
|
||||
App::DocumentObject* feature = transformFeatures[row];
|
||||
transformFeatures.erase(transformFeatures.begin() + row);
|
||||
QListWidgetItem* item = new QListWidgetItem(*(ui->listTransformFeatures->item(row)));
|
||||
ui->listTransformFeatures->model()->removeRow(row);
|
||||
|
@ -373,19 +359,10 @@ void TaskMultiTransformParameters::onSubTaskButtonOK() {
|
|||
closeSubTask();
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::onUpdateView(bool on)
|
||||
{
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
}
|
||||
|
||||
|
||||
const std::vector<App::DocumentObject*> TaskMultiTransformParameters::getTransformFeatures(void) const
|
||||
{
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
|
|
|
@ -77,8 +77,6 @@ private Q_SLOTS:
|
|||
void onTransformAddScaled();
|
||||
void onMoveUp();
|
||||
void onMoveDown();
|
||||
virtual void onButtonReference() {}
|
||||
virtual void onOriginalDeleted();
|
||||
virtual void onUpdateView(bool);
|
||||
/// User finished editing a subFeature
|
||||
virtual void onSubTaskButtonOK();
|
||||
|
|
|
@ -15,14 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Originals</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
|
@ -44,6 +48,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -62,6 +62,8 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(ViewProviderTransformed *
|
|||
ui->buttonOK->hide();
|
||||
ui->checkBoxUpdateView->setEnabled(true);
|
||||
|
||||
referenceSelectionMode = false;
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
@ -79,9 +81,12 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(TaskMultiTransformParamet
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
referenceSelectionMode = false;
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
@ -100,35 +105,24 @@ void TaskPolarPatternParameters::setupUI()
|
|||
this, SLOT(onAngle(double)));
|
||||
connect(ui->spinOccurrences, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(onOccurrences(int)));
|
||||
connect(ui->buttonReference, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonReference()));
|
||||
connect(ui->buttonReference, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonReference(bool)));
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskPolarPatternParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcPolarPattern->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->buttonX->setEnabled(true);
|
||||
|
@ -144,7 +138,8 @@ void TaskPolarPatternParameters::setupUI()
|
|||
|
||||
void TaskPolarPatternParameters::updateUI()
|
||||
{
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
updateUIinProgress = true;
|
||||
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
@ -156,9 +151,9 @@ void TaskPolarPatternParameters::updateUI()
|
|||
double angle = pcPolarPattern->Angle.getValue();
|
||||
unsigned occurrences = pcPolarPattern->Occurrences.getValue();
|
||||
|
||||
if ((featureSelectionMode || insideMultiTransform) && !stdAxis.empty())
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
if (!stdAxis.empty())
|
||||
{
|
||||
ui->buttonReference->setDown(false);
|
||||
ui->buttonX->setAutoExclusive(true);
|
||||
ui->buttonY->setAutoExclusive(true);
|
||||
ui->buttonZ->setAutoExclusive(true);
|
||||
|
@ -166,19 +161,20 @@ void TaskPolarPatternParameters::updateUI()
|
|||
ui->buttonY->setChecked(stdAxis == "Y");
|
||||
ui->buttonZ->setChecked(stdAxis == "Z");
|
||||
ui->lineReference->setText(tr(""));
|
||||
} else if ((axisFeature != NULL) && !axes.empty()) {
|
||||
} else if (axisFeature != NULL && !axes.empty()) {
|
||||
ui->buttonX->setAutoExclusive(false);
|
||||
ui->buttonY->setAutoExclusive(false);
|
||||
ui->buttonZ->setAutoExclusive(false);
|
||||
ui->buttonX->setChecked(false);
|
||||
ui->buttonY->setChecked(false);
|
||||
ui->buttonZ->setChecked(false);
|
||||
ui->buttonReference->setDown(!featureSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(axes.front().c_str()));
|
||||
} else {
|
||||
// Error message?
|
||||
ui->lineReference->setText(tr(""));
|
||||
}
|
||||
if (referenceSelectionMode)
|
||||
ui->lineReference->setText(tr("Select an edge"));
|
||||
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
ui->spinAngle->setValue(angle);
|
||||
|
@ -189,59 +185,32 @@ void TaskPolarPatternParameters::updateUI()
|
|||
|
||||
void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
App::DocumentObject* selectedObject = pcPolarPattern->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
return;
|
||||
|
||||
std::string element(msg.pSubName);
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
if (element.substr(0,4) != "Edge")
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
std::string subName(msg.pSubName);
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
if (originalSelectionMode) {
|
||||
App::DocumentObject* selectedObject = pcPolarPattern->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
// TODO
|
||||
// if (originalElementName == "") {
|
||||
// Base::Console().Error("Element created by this pattern cannot be used for axis\n");
|
||||
// return;
|
||||
// }
|
||||
if (originalSelected(msg))
|
||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else if (referenceSelectionMode &&
|
||||
(subName.size() > 4 && subName.substr(0,4) == "Edge")) {
|
||||
|
||||
std::vector<std::string> axes;
|
||||
axes.push_back(element.c_str());
|
||||
axes.push_back(subName.c_str());
|
||||
pcPolarPattern->Axis.setValue(getOriginalObject(), axes);
|
||||
pcPolarPattern->StdAxis.setValue("");
|
||||
|
||||
if (insideMultiTransform) {
|
||||
if (parentTask->updateView())
|
||||
recomputeFeature();
|
||||
} else
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true; // Jump back to selection of originals
|
||||
|
||||
showObject();
|
||||
hideOriginals();
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onButtonX() {
|
||||
onStdAxis("X");
|
||||
}
|
||||
|
@ -255,55 +224,66 @@ void TaskPolarPatternParameters::onButtonZ() {
|
|||
}
|
||||
|
||||
void TaskPolarPatternParameters::onCheckReverse(const bool on) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Reversed.setValue(on);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onAngle(const double a) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Angle.setValue(a);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onOccurrences(const int n) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Occurrences.setValue(n);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onStdAxis(const std::string& axis) {
|
||||
if (updateUIinProgress) return;
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->StdAxis.setValue(axis.c_str());
|
||||
pcPolarPattern->Axis.setValue(NULL);
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true;
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onButtonReference()
|
||||
void TaskPolarPatternParameters::onButtonReference(bool checked)
|
||||
{
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->StdAxis.setValue("");
|
||||
featureSelectionMode = false;
|
||||
hideObject();
|
||||
showOriginals();
|
||||
if (updateUIinProgress)
|
||||
return;
|
||||
if (checked ) {
|
||||
hideObject();
|
||||
showOriginals();
|
||||
referenceSelectionMode = true;
|
||||
Gui::Selection().clearSelection();
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
@ -312,7 +292,6 @@ void TaskPolarPatternParameters::onUpdateView(bool on)
|
|||
ui->buttonX->blockSignals(!on);
|
||||
ui->buttonY->blockSignals(!on);
|
||||
ui->buttonZ->blockSignals(!on);
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
ui->checkReverse->blockSignals(!on);
|
||||
ui->spinAngle->blockSignals(!on);
|
||||
ui->spinOccurrences->blockSignals(!on);
|
||||
|
@ -370,6 +349,23 @@ const unsigned TaskPolarPatternParameters::getOccurrences(void) const
|
|||
return ui->spinOccurrences->value();
|
||||
}
|
||||
|
||||
const bool TaskPolarPatternParameters::updateView() const
|
||||
{
|
||||
if (insideMultiTransform)
|
||||
return parentTask->updateView();
|
||||
else
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::exitSelectionMode()
|
||||
{
|
||||
originalSelectionMode = false;
|
||||
referenceSelectionMode = false;
|
||||
showObject();
|
||||
hideOriginals();
|
||||
}
|
||||
|
||||
|
||||
TaskPolarPatternParameters::~TaskPolarPatternParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
const bool getReverse(void) const;
|
||||
const double getAngle(void) const;
|
||||
const unsigned getOccurrences(void) const;
|
||||
const bool updateView() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onStdAxis(const std::string& axis);
|
||||
|
@ -70,17 +71,19 @@ private Q_SLOTS:
|
|||
void onCheckReverse(const bool on);
|
||||
void onAngle(const double a);
|
||||
void onOccurrences(const int n);
|
||||
virtual void onButtonReference();
|
||||
virtual void onOriginalDeleted();
|
||||
void onButtonReference(const bool checked);
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
bool referenceSelectionMode;
|
||||
|
||||
private:
|
||||
void updateUI();
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
void exitSelectionMode();
|
||||
|
||||
private:
|
||||
Ui_TaskPolarPatternParameters* ui;
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
|
@ -52,6 +63,9 @@
|
|||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -132,6 +146,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -79,7 +79,8 @@ TaskScaledParameters::TaskScaledParameters(TaskMultiTransformParameters *parentT
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
|
@ -95,30 +96,19 @@ void TaskScaledParameters::setupUI()
|
|||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskScaledParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcScaled->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->spinFactor->setEnabled(true);
|
||||
|
@ -150,29 +140,19 @@ void TaskScaledParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
return;
|
||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onFactor(const double f) {
|
||||
if (updateUIinProgress) return;
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
pcScaled->Factor.setValue(f);
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onOccurrences(const int n) {
|
||||
|
@ -180,14 +160,12 @@ void TaskScaledParameters::onOccurrences(const int n) {
|
|||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
pcScaled->Occurrences.setValue(n);
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
if (updateView())
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onUpdateView(bool on)
|
||||
{
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
ui->spinFactor->blockSignals(!on);
|
||||
ui->spinOccurrences->blockSignals(!on);
|
||||
}
|
||||
|
@ -202,6 +180,14 @@ const unsigned TaskScaledParameters::getOccurrences(void) const
|
|||
return ui->spinOccurrences->value();
|
||||
}
|
||||
|
||||
const bool TaskScaledParameters::updateView() const
|
||||
{
|
||||
if (insideMultiTransform)
|
||||
return parentTask->updateView();
|
||||
else
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
TaskScaledParameters::~TaskScaledParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
|
|
@ -58,12 +58,11 @@ public:
|
|||
|
||||
const double getFactor(void) const;
|
||||
const unsigned getOccurrences(void) const;
|
||||
const bool updateView() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFactor(const double f);
|
||||
void onOccurrences(const int n);
|
||||
virtual void onButtonReference() {}
|
||||
virtual void onOriginalDeleted();
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
|
@ -71,8 +70,8 @@ protected:
|
|||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
private:
|
||||
void updateUI();
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
|
||||
private:
|
||||
Ui_TaskScaledParameters* ui;
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
|
@ -86,6 +97,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -57,8 +57,7 @@ TaskTransformedParameters::TaskTransformedParameters(ViewProviderTransformed *Tr
|
|||
insideMultiTransform(false),
|
||||
updateUIinProgress(false)
|
||||
{
|
||||
// Start in feature selection mode
|
||||
featureSelectionMode = true;
|
||||
originalSelectionMode = false;
|
||||
}
|
||||
|
||||
TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameters *parentTask)
|
||||
|
@ -68,14 +67,13 @@ TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameter
|
|||
insideMultiTransform(true),
|
||||
updateUIinProgress(false)
|
||||
{
|
||||
// Start in reference selection mode and stay there! Feature selection makes
|
||||
// no sense inside a MultiTransform
|
||||
featureSelectionMode = false;
|
||||
// Original feature selection makes no sense inside a MultiTransform
|
||||
originalSelectionMode = false;
|
||||
}
|
||||
|
||||
const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (featureSelectionMode && (msg.Type == Gui::SelectionChanges::AddSelection)) {
|
||||
if (originalSelectionMode && (msg.Type == Gui::SelectionChanges::AddSelection)) {
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
App::DocumentObject* selectedObject = pcTransformed->getDocument()->getActiveObject();
|
||||
if (!selectedObject->isDerivedFrom(PartDesign::Additive::getClassTypeId()) &&
|
||||
|
@ -87,9 +85,11 @@ const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChang
|
|||
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
|
||||
|
||||
if (std::find(originals.begin(), originals.end(), selectedObject) == originals.end()) {
|
||||
originals.push_back(selectedObject);
|
||||
pcTransformed->Originals.setValues(originals);
|
||||
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.Originals = [App.activeDocument().%s]",
|
||||
getObject()->getNameInDocument(),
|
||||
selectedObject->getNameInDocument() );
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
originalSelectionMode = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -97,15 +97,6 @@ const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChang
|
|||
return false;
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::onOriginalDeleted(const int row)
|
||||
{
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
|
||||
originals.erase(originals.begin() + row);
|
||||
pcTransformed->Originals.setValues(originals);
|
||||
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
||||
}
|
||||
|
||||
PartDesign::Transformed *TaskTransformedParameters::getObject() const
|
||||
{
|
||||
|
||||
|
|
|
@ -62,24 +62,19 @@ public:
|
|||
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void onButtonReference() = 0;
|
||||
virtual void onOriginalDeleted() = 0;
|
||||
virtual void onUpdateView(bool) = 0;
|
||||
|
||||
/// Connect the subTask OK button to the MultiTransform task
|
||||
virtual void onSubTaskButtonOK() {}
|
||||
|
||||
protected:
|
||||
void onOriginalDeleted(const int row);
|
||||
const bool originalSelected(const Gui::SelectionChanges& msg);
|
||||
|
||||
/// Get the TransformedFeature object associated with this task
|
||||
// Either through the ViewProvider or the currently active subFeature of the parentTask
|
||||
PartDesign::Transformed *getObject() const;
|
||||
/// Recompute either this feature or the parent feature (MultiTransform mode)
|
||||
void recomputeFeature();
|
||||
/// Get the original object either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
||||
App::DocumentObject* getOriginalObject() const;
|
||||
/// Recompute either this feature or the parent feature (MultiTransform mode)
|
||||
void recomputeFeature();
|
||||
|
||||
void hideObject();
|
||||
void showObject();
|
||||
|
@ -93,7 +88,7 @@ protected:
|
|||
protected:
|
||||
QWidget* proxy;
|
||||
ViewProviderTransformed *TransformedView;
|
||||
bool featureSelectionMode;
|
||||
bool originalSelectionMode;
|
||||
|
||||
/// The MultiTransform parent task of this task
|
||||
TaskMultiTransformParameters* parentTask;
|
||||
|
|
Loading…
Reference in New Issue
Block a user