PD: [skip ci] PolarPattern: Support 1 occurrence

This is analogous to support 1 occurrence of the linear pattern feature: 81a5ec5e55
This commit is contained in:
wmayer
2021-03-01 13:58:02 +01:00
parent f481c47123
commit 356db441a6
2 changed files with 15 additions and 11 deletions

View File

@@ -71,10 +71,19 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
if (angle < Precision::Confusion())
throw Base::ValueError("Pattern angle too small");
int occurrences = Occurrences.getValue();
if (occurrences < 2)
throw Base::ValueError("At least two occurrences required");
bool reversed = Reversed.getValue();
if (occurrences < 1)
throw Base::ValueError("At least one occurrence required");
// Note: The original feature is NOT included in the list of transformations! Therefore
// we start with occurrence number 1, not number 0
std::list<gp_Trsf> transformations;
gp_Trsf trans;
transformations.push_back(trans); // identity transformation
if (occurrences < 2)
return transformations;
bool reversed = Reversed.getValue();
double offset;
if (std::fabs(angle - 360.0) < Precision::Confusion())
offset = Base::toRadians<double>(angle) / occurrences; // Because e.g. two occurrences in 360 degrees need to be 180 degrees apart
@@ -151,12 +160,6 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
if (reversed)
axis.SetDirection(axis.Direction().Reversed());
// Note: The original feature is NOT included in the list of transformations! Therefore
// we start with occurrence number 1, not number 0
std::list<gp_Trsf> transformations;
gp_Trsf trans;
transformations.push_back(trans); // identity transformation
for (int i = 1; i < occurrences; i++) {
trans.SetRotation(axis.Axis(), i * offset);
transformations.push_back(trans);

View File

@@ -121,6 +121,9 @@ void TaskPolarPatternParameters::setupUI()
connect(ui->listWidgetFeatures->model(),
SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), this, SLOT(indexesMoved()));
ui->spinOccurrences->setMaximum(INT_MAX);
ui->spinOccurrences->setMinimum(1);
updateViewTimer = new QTimer(this);
updateViewTimer->setSingleShot(true);
updateViewTimer->setInterval(getUpdateViewTimeout());
@@ -155,8 +158,6 @@ void TaskPolarPatternParameters::setupUI()
// ---------------------
ui->polarAngle->bind(pcPolarPattern->Angle);
ui->spinOccurrences->setMaximum(INT_MAX);
ui->spinOccurrences->setMinimum(2);
ui->spinOccurrences->bind(pcPolarPattern->Occurrences);
ui->comboAxis->setEnabled(true);