New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PD] Pad/Pocket: sort out duplicated code #5355
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,70 +80,8 @@ void TaskPadParameters::updateUI(int index) | |
{ | ||
// update direction combobox | ||
fillDirectionCombo(); | ||
|
||
// disable/hide everything unless we are sure we don't need it | ||
// exception: the direction parameters are in any case visible | ||
bool isLengthEditVisible = false; | ||
bool isLengthEdit2Visible = false; | ||
bool isOffsetEditVisible = false; | ||
bool isMidplaneEnabled = false; | ||
bool isMidplaneVisible = false; | ||
bool isReversedEnabled = false; | ||
bool isFaceEditEnabled = false; | ||
|
||
Modes mode = static_cast<Modes>(index); | ||
|
||
if (mode == Modes::Dimension) { | ||
isLengthEditVisible = true; | ||
ui->lengthEdit->selectNumber(); | ||
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection); | ||
isMidplaneEnabled = !ui->checkBoxReversed->isChecked(); | ||
isMidplaneVisible = true; | ||
// Reverse only makes sense if Midplane is not true | ||
isReversedEnabled = !ui->checkBoxMidplane->isChecked(); | ||
} | ||
else if (mode == Modes::ToLast || mode == Modes::ToFirst) { | ||
isOffsetEditVisible = true; | ||
isReversedEnabled = true; | ||
} | ||
else if (mode == Modes::ToFace) { | ||
isOffsetEditVisible = true; | ||
isFaceEditEnabled = true; | ||
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection); | ||
// Go into reference selection mode if no face has been selected yet | ||
if (ui->lineFaceName->property("FeatureName").isNull()) | ||
onButtonFace(true); | ||
isReversedEnabled = true; | ||
} | ||
else if (mode == Modes::TwoDimensions) { | ||
isLengthEditVisible = true; | ||
isLengthEdit2Visible = true; | ||
isReversedEnabled = true; | ||
} | ||
|
||
ui->lengthEdit->setVisible( isLengthEditVisible ); | ||
ui->lengthEdit->setEnabled( isLengthEditVisible ); | ||
ui->labelLength->setVisible( isLengthEditVisible ); | ||
ui->checkBoxAlongDirection->setVisible( isLengthEditVisible ); | ||
|
||
ui->offsetEdit->setVisible( isOffsetEditVisible ); | ||
ui->offsetEdit->setEnabled( isOffsetEditVisible ); | ||
ui->labelOffset->setVisible( isOffsetEditVisible ); | ||
|
||
ui->checkBoxMidplane->setEnabled( isMidplaneEnabled ); | ||
ui->checkBoxMidplane->setVisible( isMidplaneVisible ); | ||
|
||
ui->checkBoxReversed->setEnabled( isReversedEnabled ); | ||
|
||
ui->lengthEdit2->setVisible( isLengthEdit2Visible ); | ||
ui->lengthEdit2->setEnabled( isLengthEdit2Visible ); | ||
ui->labelLength2->setVisible( isLengthEdit2Visible ); | ||
|
||
ui->buttonFace->setEnabled( isFaceEditEnabled ); | ||
ui->lineFaceName->setEnabled( isFaceEditEnabled ); | ||
if (!isFaceEditEnabled) { | ||
onButtonFace(false); | ||
} | ||
// set and enable checkboxes | ||
setCheckboxes(index, static_cast<Modes>(index)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't make much sense. Why is index passed twice now? In my code example the second argument was supposed to be new enum class type:
The called function would then be: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good question. I have no clue why I force-pushed this. Before my last push the enum was correctly passed. I see now that you already fixed and merged. Many thanks. |
||
} | ||
|
||
void TaskPadParameters::onModeChanged(int index) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToLast is equal to ThroughAll and thus this else block is dead code. So, what's still needed is the extrude type (Pad or Pocket) to make sure ThroughAll is only handled for Pockets and ToLast only for Pads.