PD: Add offset / overall angle modes for PolarPatterns
This commit adds two separate modes for defining angular spacing between elements in the PD's Polar Pattern: 1. Overall Angle - which behaves exactly like it behaved before, 2. Offset Angle - which allows user to specify separation angle between consecutive elements. This change is analogue to that introduced for LinearPattern in previous commits.
This commit is contained in:
@@ -131,10 +131,14 @@ void TaskPolarPatternParameters::connectSignals()
|
||||
this, &TaskPolarPatternParameters::onUpdateViewTimer);
|
||||
connect(ui->comboAxis, qOverload<int>(&QComboBox::activated),
|
||||
this, &TaskPolarPatternParameters::onAxisChanged);
|
||||
connect(ui->comboMode, qOverload<int>(&QComboBox::activated),
|
||||
this, &TaskPolarPatternParameters::onModeChanged);
|
||||
connect(ui->checkReverse, &QCheckBox::toggled,
|
||||
this, &TaskPolarPatternParameters::onCheckReverse);
|
||||
connect(ui->polarAngle, qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
|
||||
this, &TaskPolarPatternParameters::onAngle);
|
||||
connect(ui->angleOffset, qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
|
||||
this, &TaskPolarPatternParameters::onOffset);
|
||||
connect(ui->spinOccurrences, &Gui::UIntSpinBox::unsignedChanged,
|
||||
this, &TaskPolarPatternParameters::onOccurrences);
|
||||
connect(ui->checkBoxUpdateView, &QCheckBox::toggled,
|
||||
@@ -159,11 +163,14 @@ void TaskPolarPatternParameters::setupUI()
|
||||
// ---------------------
|
||||
|
||||
ui->polarAngle->bind(pcPolarPattern->Angle);
|
||||
ui->angleOffset->bind(pcPolarPattern->Offset);
|
||||
|
||||
ui->spinOccurrences->bind(pcPolarPattern->Occurrences);
|
||||
ui->spinOccurrences->setMaximum(pcPolarPattern->Occurrences.getMaximum());
|
||||
ui->spinOccurrences->setMinimum(pcPolarPattern->Occurrences.getMinimum());
|
||||
|
||||
ui->comboAxis->setEnabled(true);
|
||||
ui->comboMode->setEnabled(true);
|
||||
ui->checkReverse->setEnabled(true);
|
||||
ui->polarAngle->setEnabled(true);
|
||||
ui->spinOccurrences->setEnabled(true);
|
||||
@@ -191,6 +198,7 @@ void TaskPolarPatternParameters::setupUI()
|
||||
}
|
||||
}
|
||||
|
||||
adaptVisibilityToMode();
|
||||
updateUI();
|
||||
connectSignals();
|
||||
}
|
||||
@@ -203,20 +211,24 @@ void TaskPolarPatternParameters::updateUI()
|
||||
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
||||
PartDesign::PolarPatternMode mode = static_cast<PartDesign::PolarPatternMode>(pcPolarPattern->Mode.getValue());
|
||||
bool reverse = pcPolarPattern->Reversed.getValue();
|
||||
double angle = pcPolarPattern->Angle.getValue();
|
||||
double offset = pcPolarPattern->Offset.getValue();
|
||||
unsigned occurrences = pcPolarPattern->Occurrences.getValue();
|
||||
|
||||
if (axesLinks.setCurrentLink(pcPolarPattern->Axis) == -1){
|
||||
if (axesLinks.setCurrentLink(pcPolarPattern->Axis) == -1) {
|
||||
//failed to set current, because the link isn't in the list yet
|
||||
axesLinks.addLink(pcPolarPattern->Axis, getRefStr(pcPolarPattern->Axis.getValue(),pcPolarPattern->Axis.getSubValues()));
|
||||
axesLinks.setCurrentLink(pcPolarPattern->Axis);
|
||||
}
|
||||
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for blockUpdate
|
||||
// Note: This block of code would trigger change signal handlers (e.g. onOccurrences())
|
||||
// and another updateUI() if we didn't check for blockUpdate
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
ui->comboMode->setCurrentIndex((long)mode);
|
||||
ui->polarAngle->setValue(angle);
|
||||
ui->angleOffset->setValue(offset);
|
||||
ui->spinOccurrences->setValue(occurrences);
|
||||
|
||||
blockUpdate = false;
|
||||
@@ -233,6 +245,15 @@ void TaskPolarPatternParameters::kickUpdateViewTimer() const
|
||||
updateViewTimer->start();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::adaptVisibilityToMode()
|
||||
{
|
||||
auto pcLinearPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
auto mode = static_cast<PartDesign::PolarPatternMode>(pcLinearPattern->Mode.getValue());
|
||||
|
||||
ui->polarAngleWrapper->setVisible(mode == PartDesign::PolarPatternMode::angle);
|
||||
ui->angleOffsetWrapper->setVisible(mode == PartDesign::PolarPatternMode::offset);
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::addObject(App::DocumentObject* obj)
|
||||
{
|
||||
QString label = QString::fromUtf8(obj->Label.getValue());
|
||||
@@ -292,6 +313,18 @@ void TaskPolarPatternParameters::onCheckReverse(const bool on) {
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onModeChanged(const int mode) {
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Mode.setValue(mode);
|
||||
|
||||
adaptVisibilityToMode();
|
||||
|
||||
exitSelectionMode();
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onAngle(const double a) {
|
||||
if (blockUpdate)
|
||||
return;
|
||||
@@ -302,6 +335,16 @@ void TaskPolarPatternParameters::onAngle(const double a) {
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onOffset(const double a) {
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Offset.setValue(a);
|
||||
|
||||
exitSelectionMode();
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onOccurrences(const uint n) {
|
||||
if (blockUpdate)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user