PartDesign/Task{Pad,Pocket}Parameters: massive refactoring
Give a massive refactoring to Task dialogs for pocket and pad. This commit features: * Make Task dialogs for pocket and pad look nice in side-by side diff and cross import features missing in each other. * As a result it fixes several minor bugs. * Gives a rework to the UpdateUI function. * This one also fixes offset option support and migrates it to use unit framework.
This commit is contained in:
parent
143760c8d3
commit
0ca40ed48b
|
@ -69,7 +69,7 @@ Pad::Pad()
|
||||||
ADD_PROPERTY_TYPE(Length,(100.0),"Pad",App::Prop_None,"Pad length");
|
ADD_PROPERTY_TYPE(Length,(100.0),"Pad",App::Prop_None,"Pad length");
|
||||||
ADD_PROPERTY_TYPE(Length2,(100.0),"Pad",App::Prop_None,"P");
|
ADD_PROPERTY_TYPE(Length2,(100.0),"Pad",App::Prop_None,"P");
|
||||||
ADD_PROPERTY_TYPE(UpToFace,(0),"Pad",App::Prop_None,"Face where pad will end");
|
ADD_PROPERTY_TYPE(UpToFace,(0),"Pad",App::Prop_None,"Face where pad will end");
|
||||||
ADD_PROPERTY(Offset,(0.0));
|
ADD_PROPERTY_TYPE(Offset,(0.0),"Pad",App::Prop_None,"Offset from face in which pad will end");
|
||||||
}
|
}
|
||||||
|
|
||||||
short Pad::mustExecute() const
|
short Pad::mustExecute() const
|
||||||
|
@ -78,6 +78,7 @@ short Pad::mustExecute() const
|
||||||
Type.isTouched() ||
|
Type.isTouched() ||
|
||||||
Length.isTouched() ||
|
Length.isTouched() ||
|
||||||
Length2.isTouched() ||
|
Length2.isTouched() ||
|
||||||
|
Offset.isTouched() ||
|
||||||
UpToFace.isTouched())
|
UpToFace.isTouched())
|
||||||
return 1;
|
return 1;
|
||||||
return SketchBased::mustExecute();
|
return SketchBased::mustExecute();
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
App::PropertyEnumeration Type;
|
App::PropertyEnumeration Type;
|
||||||
App::PropertyLength Length;
|
App::PropertyLength Length;
|
||||||
App::PropertyLength Length2;
|
App::PropertyLength Length2;
|
||||||
App::PropertyFloat Offset;
|
App::PropertyLength Offset;
|
||||||
|
|
||||||
/** @name methods override feature */
|
/** @name methods override feature */
|
||||||
//@{
|
//@{
|
||||||
|
|
|
@ -64,7 +64,7 @@ Pocket::Pocket()
|
||||||
Type.setEnums(TypeEnums);
|
Type.setEnums(TypeEnums);
|
||||||
ADD_PROPERTY_TYPE(Length,(100.0),"Pocket",App::Prop_None,"Pocket length");
|
ADD_PROPERTY_TYPE(Length,(100.0),"Pocket",App::Prop_None,"Pocket length");
|
||||||
ADD_PROPERTY_TYPE(UpToFace,(0),"Pocket",App::Prop_None,"Face where pocket will end");
|
ADD_PROPERTY_TYPE(UpToFace,(0),"Pocket",App::Prop_None,"Face where pocket will end");
|
||||||
ADD_PROPERTY(Offset,(0.0));
|
ADD_PROPERTY_TYPE(Offset,(0.0),"Pad",App::Prop_None,"Offset from face in which pad will end");
|
||||||
}
|
}
|
||||||
|
|
||||||
short Pocket::mustExecute() const
|
short Pocket::mustExecute() const
|
||||||
|
@ -72,6 +72,7 @@ short Pocket::mustExecute() const
|
||||||
if (Placement.isTouched() ||
|
if (Placement.isTouched() ||
|
||||||
Type.isTouched() ||
|
Type.isTouched() ||
|
||||||
Length.isTouched() ||
|
Length.isTouched() ||
|
||||||
|
Offset.isTouched() ||
|
||||||
UpToFace.isTouched())
|
UpToFace.isTouched())
|
||||||
return 1;
|
return 1;
|
||||||
return SketchBased::mustExecute();
|
return SketchBased::mustExecute();
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
App::PropertyEnumeration Type;
|
App::PropertyEnumeration Type;
|
||||||
App::PropertyLength Length;
|
App::PropertyLength Length;
|
||||||
App::PropertyFloat Offset;
|
App::PropertyLength Offset;
|
||||||
|
|
||||||
/** @name methods override feature */
|
/** @name methods override feature */
|
||||||
//@{
|
//@{
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
# include <sstream>
|
# include <sstream>
|
||||||
# include <QRegExp>
|
# include <QRegExp>
|
||||||
# include <QTextStream>
|
# include <QTextStream>
|
||||||
# include <QMessageBox>
|
|
||||||
# include <Precision.hxx>
|
# include <Precision.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ using namespace Gui;
|
||||||
|
|
||||||
/* TRANSLATOR PartDesignGui::TaskPadParameters */
|
/* TRANSLATOR PartDesignGui::TaskPadParameters */
|
||||||
|
|
||||||
TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidget *parent)
|
TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView, QWidget *parent, bool newObj)
|
||||||
: TaskSketchBasedParameters(PadView, parent, "PartDesign_Pad",tr("Pad parameters"))
|
: TaskSketchBasedParameters(PadView, parent, "PartDesign_Pad",tr("Pad parameters"))
|
||||||
{
|
{
|
||||||
// we need a separate container widget to add all controls to
|
// we need a separate container widget to add all controls to
|
||||||
|
@ -67,14 +66,15 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg
|
||||||
// set the history path
|
// set the history path
|
||||||
ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength"));
|
ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength"));
|
||||||
ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength2"));
|
ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength2"));
|
||||||
|
ui->offsetEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadOffset"));
|
||||||
|
|
||||||
// Get the feature data
|
// Get the feature data
|
||||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||||
Base::Quantity l = pcPad->Length.getQuantityValue();
|
Base::Quantity l = pcPad->Length.getQuantityValue();
|
||||||
|
Base::Quantity l2 = pcPad->Length2.getQuantityValue();
|
||||||
|
Base::Quantity off = pcPad->Offset.getQuantityValue();
|
||||||
bool midplane = pcPad->Midplane.getValue();
|
bool midplane = pcPad->Midplane.getValue();
|
||||||
bool reversed = pcPad->Reversed.getValue();
|
bool reversed = pcPad->Reversed.getValue();
|
||||||
Base::Quantity l2 = pcPad->Length2.getQuantityValue();
|
|
||||||
double off = pcPad->Offset.getValue();
|
|
||||||
int index = pcPad->Type.getValue(); // must extract value here, clear() kills it!
|
int index = pcPad->Type.getValue(); // must extract value here, clear() kills it!
|
||||||
App::DocumentObject* obj = pcPad->UpToFace.getValue();
|
App::DocumentObject* obj = pcPad->UpToFace.getValue();
|
||||||
std::vector<std::string> subStrings = pcPad->UpToFace.getSubValues();
|
std::vector<std::string> subStrings = pcPad->UpToFace.getSubValues();
|
||||||
|
@ -87,15 +87,9 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill data into dialog elements
|
// Fill data into dialog elements
|
||||||
ui->lengthEdit->setMinimum(0);
|
|
||||||
ui->lengthEdit->setMaximum(INT_MAX);
|
|
||||||
ui->lengthEdit->setValue(l);
|
ui->lengthEdit->setValue(l);
|
||||||
ui->lengthEdit2->setMinimum(0);
|
|
||||||
ui->lengthEdit2->setMaximum(INT_MAX);
|
|
||||||
ui->lengthEdit2->setValue(l2);
|
ui->lengthEdit2->setValue(l2);
|
||||||
ui->spinOffset->setMaximum(INT_MAX);
|
ui->offsetEdit->setValue(off);
|
||||||
ui->spinOffset->setMinimum(-INT_MAX);
|
|
||||||
ui->spinOffset->setValue(off);
|
|
||||||
|
|
||||||
// Bind input fields to properties
|
// Bind input fields to properties
|
||||||
ui->lengthEdit->bind(pcPad->Length);
|
ui->lengthEdit->bind(pcPad->Length);
|
||||||
|
@ -124,14 +118,14 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg
|
||||||
|
|
||||||
connect(ui->lengthEdit, SIGNAL(valueChanged(double)),
|
connect(ui->lengthEdit, SIGNAL(valueChanged(double)),
|
||||||
this, SLOT(onLengthChanged(double)));
|
this, SLOT(onLengthChanged(double)));
|
||||||
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
|
|
||||||
this, SLOT(onMidplane(bool)));
|
|
||||||
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
|
|
||||||
this, SLOT(onReversed(bool)));
|
|
||||||
connect(ui->lengthEdit2, SIGNAL(valueChanged(double)),
|
connect(ui->lengthEdit2, SIGNAL(valueChanged(double)),
|
||||||
this, SLOT(onLength2Changed(double)));
|
this, SLOT(onLength2Changed(double)));
|
||||||
connect(ui->spinOffset, SIGNAL(valueChanged(double)),
|
connect(ui->offsetEdit, SIGNAL(valueChanged(double)),
|
||||||
this, SLOT(onOffsetChanged(double)));
|
this, SLOT(onOffsetChanged(double)));
|
||||||
|
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(onMidplaneChanged(bool)));
|
||||||
|
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(onReversedChanged(bool)));
|
||||||
connect(ui->changeMode, SIGNAL(currentIndexChanged(int)),
|
connect(ui->changeMode, SIGNAL(currentIndexChanged(int)),
|
||||||
this, SLOT(onModeChanged(int)));
|
this, SLOT(onModeChanged(int)));
|
||||||
connect(ui->buttonFace, SIGNAL(clicked()),
|
connect(ui->buttonFace, SIGNAL(clicked()),
|
||||||
|
@ -141,87 +135,74 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg
|
||||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(onUpdateView(bool)));
|
this, SLOT(onUpdateView(bool)));
|
||||||
|
|
||||||
|
// Due to signals attached after changes took took into effect we should update the UI now.
|
||||||
|
updateUI(index);
|
||||||
|
|
||||||
// if it is a newly created object use the last value of the history
|
// if it is a newly created object use the last value of the history
|
||||||
if(newObj){
|
if(newObj){
|
||||||
ui->lengthEdit->setToLastUsedValue();
|
ui->lengthEdit->setToLastUsedValue();
|
||||||
ui->lengthEdit->selectNumber();
|
ui->lengthEdit->selectNumber();
|
||||||
ui->lengthEdit2->setToLastUsedValue();
|
ui->lengthEdit2->setToLastUsedValue();
|
||||||
ui->lengthEdit2->selectNumber();
|
ui->lengthEdit2->selectNumber();
|
||||||
|
ui->offsetEdit->setToLastUsedValue();
|
||||||
|
ui->offsetEdit->selectNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPadParameters::updateUI(int index)
|
void TaskPadParameters::updateUI(int index)
|
||||||
{
|
{
|
||||||
|
// disable/hide evrything unless we are sure we don't need it
|
||||||
|
bool isLengthEditVisable = false;
|
||||||
|
bool isLengthEdit2Visable = false;
|
||||||
|
bool isOffsetEditVisable = false;
|
||||||
|
bool isMidplateEnabled = false;
|
||||||
|
bool isReversedEnabled = false;
|
||||||
|
bool isFaceEditEnabled = false;
|
||||||
|
|
||||||
if (index == 0) { // dimension
|
if (index == 0) { // dimension
|
||||||
ui->lengthEdit->setVisible(true);
|
isLengthEditVisable = true;
|
||||||
ui->lengthEdit->setEnabled(true);
|
|
||||||
ui->lengthEdit->selectNumber();
|
ui->lengthEdit->selectNumber();
|
||||||
ui->labelLength->setVisible(true);
|
|
||||||
ui->spinOffset->setVisible(false);
|
|
||||||
ui->spinOffset->setEnabled(false);
|
|
||||||
ui->labelOffset->setVisible(false);
|
|
||||||
// Make sure that the spin box has the focus to get key events
|
// Make sure that the spin box has the focus to get key events
|
||||||
// Calling setFocus() directly doesn't work because the spin box is not
|
// Calling setFocus() directly doesn't work because the spin box is not
|
||||||
// yet visible.
|
// yet visible.
|
||||||
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
|
||||||
ui->checkBoxMidplane->setEnabled(true);
|
isMidplateEnabled = true;
|
||||||
// Reverse only makes sense if Midplane is not true
|
// Reverse only makes sense if Midplane is not true
|
||||||
ui->checkBoxReversed->setEnabled(!ui->checkBoxMidplane->isChecked());
|
isReversedEnabled = !ui->checkBoxMidplane->isChecked();
|
||||||
ui->labelLength2->setVisible(false);
|
|
||||||
ui->lengthEdit2->setVisible(false);
|
|
||||||
ui->lengthEdit2->setEnabled(false);
|
|
||||||
ui->buttonFace->setEnabled(false);
|
|
||||||
ui->lineFaceName->setEnabled(false);
|
|
||||||
onButtonFace(false);
|
|
||||||
} else if (index == 1 || index == 2) { // up to first/last
|
} else if (index == 1 || index == 2) { // up to first/last
|
||||||
ui->lengthEdit->setVisible(false);
|
isOffsetEditVisable = true;
|
||||||
ui->lengthEdit->setEnabled(false);
|
isReversedEnabled = true;
|
||||||
ui->labelLength->setVisible(false);
|
|
||||||
ui->spinOffset->setVisible(true);
|
|
||||||
ui->spinOffset->setEnabled(true);
|
|
||||||
ui->labelOffset->setVisible(true);
|
|
||||||
ui->checkBoxMidplane->setEnabled(false);
|
|
||||||
ui->checkBoxReversed->setEnabled(true);
|
|
||||||
ui->labelLength2->setVisible(false);
|
|
||||||
ui->lengthEdit2->setVisible(false);
|
|
||||||
ui->lengthEdit2->setEnabled(false);
|
|
||||||
ui->buttonFace->setEnabled(false);
|
|
||||||
ui->lineFaceName->setEnabled(false);
|
|
||||||
onButtonFace(false);
|
|
||||||
} else if (index == 3) { // up to face
|
} else if (index == 3) { // up to face
|
||||||
ui->lengthEdit->setVisible(false);
|
isOffsetEditVisable = true;
|
||||||
ui->lengthEdit->setEnabled(false);
|
isFaceEditEnabled = true;
|
||||||
ui->labelLength->setVisible(false);
|
|
||||||
ui->spinOffset->setVisible(true);
|
|
||||||
ui->spinOffset->setEnabled(true);
|
|
||||||
ui->labelOffset->setVisible(true);
|
|
||||||
ui->checkBoxMidplane->setEnabled(false);
|
|
||||||
ui->checkBoxReversed->setEnabled(false);
|
|
||||||
ui->labelLength2->setVisible(false);
|
|
||||||
ui->lengthEdit2->setVisible(false);
|
|
||||||
ui->lengthEdit2->setEnabled(false);
|
|
||||||
ui->buttonFace->setEnabled(true);
|
|
||||||
ui->lineFaceName->setEnabled(true);
|
|
||||||
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
|
||||||
// Go into reference selection mode if no face has been selected yet
|
// Go into reference selection mode if no face has been selected yet
|
||||||
if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected")))
|
if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected")))
|
||||||
onButtonFace(true);
|
onButtonFace(true);
|
||||||
} else { // two dimensions
|
} else { // two dimensions
|
||||||
ui->lengthEdit->setEnabled(true);
|
isLengthEditVisable = true;
|
||||||
ui->lengthEdit->setVisible(true);
|
isLengthEdit2Visable = true;
|
||||||
ui->lengthEdit->selectNumber();
|
}
|
||||||
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
|
|
||||||
ui->labelLength->setVisible(true);
|
ui->lengthEdit->setVisible( isLengthEditVisable );
|
||||||
ui->spinOffset->setVisible(false);
|
ui->lengthEdit->setEnabled( isLengthEditVisable );
|
||||||
ui->spinOffset->setEnabled(false);
|
ui->labelLength->setVisible( isLengthEditVisable );
|
||||||
ui->labelOffset->setVisible(false);
|
|
||||||
ui->checkBoxMidplane->setEnabled(false);
|
ui->offsetEdit->setVisible( isOffsetEditVisable );
|
||||||
ui->checkBoxReversed->setEnabled(false);
|
ui->offsetEdit->setEnabled( isOffsetEditVisable );
|
||||||
ui->labelLength2->setVisible(true);
|
ui->labelOffset->setVisible( isOffsetEditVisable );
|
||||||
ui->lengthEdit2->setVisible(true);
|
|
||||||
ui->lengthEdit2->setEnabled(true);
|
ui->checkBoxMidplane->setEnabled( isMidplateEnabled );
|
||||||
ui->buttonFace->setEnabled(false);
|
|
||||||
ui->lineFaceName->setEnabled(false);
|
ui->checkBoxReversed->setEnabled( isReversedEnabled );
|
||||||
|
|
||||||
|
ui->lengthEdit2->setVisible( isLengthEdit2Visable );
|
||||||
|
ui->lengthEdit2->setEnabled( isLengthEdit2Visable );
|
||||||
|
ui->labelLength2->setVisible( isLengthEdit2Visable );
|
||||||
|
|
||||||
|
ui->buttonFace->setEnabled( isFaceEditEnabled );
|
||||||
|
ui->lineFaceName->setEnabled( isFaceEditEnabled );
|
||||||
|
if (!isFaceEditEnabled) {
|
||||||
onButtonFace(false);
|
onButtonFace(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +211,7 @@ void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
{
|
{
|
||||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||||
QString refText = onAddSelection(msg);
|
QString refText = onAddSelection(msg);
|
||||||
if (refText.length() != 0) {
|
if (refText.length() > 0) {
|
||||||
ui->lineFaceName->blockSignals(true);
|
ui->lineFaceName->blockSignals(true);
|
||||||
ui->lineFaceName->setText(refText);
|
ui->lineFaceName->setText(refText);
|
||||||
ui->lineFaceName->setProperty("FaceName", QByteArray(msg.pSubName));
|
ui->lineFaceName->setProperty("FaceName", QByteArray(msg.pSubName));
|
||||||
|
@ -243,11 +224,9 @@ void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||||
ui->lineFaceName->blockSignals(false);
|
ui->lineFaceName->blockSignals(false);
|
||||||
}
|
}
|
||||||
}
|
} else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
|
||||||
|
|
||||||
else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
|
|
||||||
ui->lineFaceName->blockSignals(true);
|
ui->lineFaceName->blockSignals(true);
|
||||||
ui->lineFaceName->setText(tr(""));
|
ui->lineFaceName->setText(tr("No face selected"));
|
||||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||||
ui->lineFaceName->blockSignals(false);
|
ui->lineFaceName->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
@ -260,21 +239,6 @@ void TaskPadParameters::onLengthChanged(double len)
|
||||||
recomputeFeature();
|
recomputeFeature();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPadParameters::onMidplane(bool on)
|
|
||||||
{
|
|
||||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
|
||||||
pcPad->Midplane.setValue(on);
|
|
||||||
ui->checkBoxReversed->setEnabled(!on);
|
|
||||||
recomputeFeature();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskPadParameters::onReversed(bool on)
|
|
||||||
{
|
|
||||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
|
||||||
pcPad->Reversed.setValue(on);
|
|
||||||
recomputeFeature();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskPadParameters::onLength2Changed(double len)
|
void TaskPadParameters::onLength2Changed(double len)
|
||||||
{
|
{
|
||||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||||
|
@ -289,6 +253,21 @@ void TaskPadParameters::onOffsetChanged(double len)
|
||||||
recomputeFeature();
|
recomputeFeature();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskPadParameters::onMidplaneChanged(bool on)
|
||||||
|
{
|
||||||
|
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||||
|
pcPad->Midplane.setValue(on);
|
||||||
|
ui->checkBoxReversed->setEnabled(!on);
|
||||||
|
recomputeFeature();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskPadParameters::onReversedChanged(bool on)
|
||||||
|
{
|
||||||
|
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||||
|
pcPad->Reversed.setValue(on);
|
||||||
|
recomputeFeature();
|
||||||
|
}
|
||||||
|
|
||||||
void TaskPadParameters::onModeChanged(int index)
|
void TaskPadParameters::onModeChanged(int index)
|
||||||
{
|
{
|
||||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||||
|
@ -310,8 +289,7 @@ void TaskPadParameters::onModeChanged(int index)
|
||||||
recomputeFeature();
|
recomputeFeature();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPadParameters::onButtonFace(const bool pressed)
|
void TaskPadParameters::onButtonFace(const bool pressed) {
|
||||||
{
|
|
||||||
TaskSketchBasedParameters::onSelectReference(pressed, false, true, false);
|
TaskSketchBasedParameters::onSelectReference(pressed, false, true, false);
|
||||||
|
|
||||||
// Update button if onButtonFace() is called explicitly
|
// Update button if onButtonFace() is called explicitly
|
||||||
|
@ -328,6 +306,16 @@ double TaskPadParameters::getLength(void) const
|
||||||
return ui->lengthEdit->value().getValue();
|
return ui->lengthEdit->value().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double TaskPadParameters::getLength2(void) const
|
||||||
|
{
|
||||||
|
return ui->lengthEdit2->value().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
double TaskPadParameters::getOffset(void) const
|
||||||
|
{
|
||||||
|
return ui->offsetEdit->value().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool TaskPadParameters::getReversed(void) const
|
bool TaskPadParameters::getReversed(void) const
|
||||||
{
|
{
|
||||||
return ui->checkBoxReversed->isChecked();
|
return ui->checkBoxReversed->isChecked();
|
||||||
|
@ -338,16 +326,6 @@ bool TaskPadParameters::getMidplane(void) const
|
||||||
return ui->checkBoxMidplane->isChecked();
|
return ui->checkBoxMidplane->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
double TaskPadParameters::getLength2(void) const
|
|
||||||
{
|
|
||||||
return ui->lengthEdit2->value().getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
double TaskPadParameters::getOffset(void) const
|
|
||||||
{
|
|
||||||
return ui->spinOffset->value();
|
|
||||||
}
|
|
||||||
|
|
||||||
int TaskPadParameters::getMode(void) const
|
int TaskPadParameters::getMode(void) const
|
||||||
{
|
{
|
||||||
return ui->changeMode->currentIndex();
|
return ui->changeMode->currentIndex();
|
||||||
|
@ -375,7 +353,7 @@ void TaskPadParameters::changeEvent(QEvent *e)
|
||||||
if (e->type() == QEvent::LanguageChange) {
|
if (e->type() == QEvent::LanguageChange) {
|
||||||
ui->lengthEdit->blockSignals(true);
|
ui->lengthEdit->blockSignals(true);
|
||||||
ui->lengthEdit2->blockSignals(true);
|
ui->lengthEdit2->blockSignals(true);
|
||||||
ui->spinOffset->blockSignals(true);
|
ui->offsetEdit->blockSignals(true);
|
||||||
ui->lineFaceName->blockSignals(true);
|
ui->lineFaceName->blockSignals(true);
|
||||||
ui->changeMode->blockSignals(true);
|
ui->changeMode->blockSignals(true);
|
||||||
int index = ui->changeMode->currentIndex();
|
int index = ui->changeMode->currentIndex();
|
||||||
|
@ -400,10 +378,10 @@ void TaskPadParameters::changeEvent(QEvent *e)
|
||||||
#endif
|
#endif
|
||||||
ui->lineFaceName->setText(ok ?
|
ui->lineFaceName->setText(ok ?
|
||||||
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
|
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
|
||||||
QString());
|
tr(""));
|
||||||
ui->lengthEdit->blockSignals(false);
|
ui->lengthEdit->blockSignals(false);
|
||||||
ui->lengthEdit2->blockSignals(false);
|
ui->lengthEdit2->blockSignals(false);
|
||||||
ui->spinOffset->blockSignals(false);
|
ui->offsetEdit->blockSignals(false);
|
||||||
ui->lineFaceName->blockSignals(false);
|
ui->lineFaceName->blockSignals(false);
|
||||||
ui->changeMode->blockSignals(false);
|
ui->changeMode->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
@ -414,6 +392,7 @@ void TaskPadParameters::saveHistory(void)
|
||||||
// save the user values to history
|
// save the user values to history
|
||||||
ui->lengthEdit->pushToHistory();
|
ui->lengthEdit->pushToHistory();
|
||||||
ui->lengthEdit2->pushToHistory();
|
ui->lengthEdit2->pushToHistory();
|
||||||
|
ui->offsetEdit->pushToHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPadParameters::apply()
|
void TaskPadParameters::apply()
|
||||||
|
@ -422,10 +401,6 @@ void TaskPadParameters::apply()
|
||||||
const char * cname = name.c_str();
|
const char * cname = name.c_str();
|
||||||
|
|
||||||
ui->lengthEdit->apply();
|
ui->lengthEdit->apply();
|
||||||
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",cname,getReversed()?1:0);
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",cname,getMidplane()?1:0);
|
|
||||||
|
|
||||||
ui->lengthEdit2->apply();
|
ui->lengthEdit2->apply();
|
||||||
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u", cname, getMode());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u", cname, getMode());
|
||||||
|
@ -437,6 +412,8 @@ void TaskPadParameters::apply()
|
||||||
} else {
|
} else {
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", cname);
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", cname);
|
||||||
}
|
}
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i", cname, getReversed()?1:0);
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i", cname, getMidplane()?1:0);
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Offset = %f", name.c_str(), getOffset());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Offset = %f", name.c_str(), getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,8 +425,8 @@ void TaskPadParameters::apply()
|
||||||
TaskDlgPadParameters::TaskDlgPadParameters(ViewProviderPad *PadView,bool newObj)
|
TaskDlgPadParameters::TaskDlgPadParameters(ViewProviderPad *PadView,bool newObj)
|
||||||
: TaskDlgSketchBasedParameters(PadView)
|
: TaskDlgSketchBasedParameters(PadView)
|
||||||
{
|
{
|
||||||
assert(PadView);
|
assert(vp);
|
||||||
parameter = new TaskPadParameters(static_cast<ViewProviderPad*>(PadView));
|
parameter = new TaskPadParameters(static_cast<ViewProviderPad*>(vp));
|
||||||
|
|
||||||
Content.push_back(parameter);
|
Content.push_back(parameter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,32 +49,33 @@ class TaskPadParameters : public TaskSketchBasedParameters
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskPadParameters(ViewProviderPad *PadView,bool newObj=false,QWidget *parent = 0);
|
TaskPadParameters(ViewProviderPad *PadView, QWidget *parent = 0, bool newObj=false);
|
||||||
~TaskPadParameters();
|
~TaskPadParameters();
|
||||||
|
|
||||||
double getOffset(void) const;
|
|
||||||
void saveHistory(void);
|
void saveHistory(void);
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onLengthChanged(double);
|
void onLengthChanged(double);
|
||||||
void onMidplane(bool);
|
|
||||||
void onReversed(bool);
|
|
||||||
void onLength2Changed(double);
|
void onLength2Changed(double);
|
||||||
void onOffsetChanged(double);
|
void onOffsetChanged(double);
|
||||||
void onModeChanged(int);
|
void onMidplaneChanged(bool);
|
||||||
|
void onReversedChanged(bool);
|
||||||
void onButtonFace(const bool pressed = true);
|
void onButtonFace(const bool pressed = true);
|
||||||
void onFaceName(const QString& text);
|
void onFaceName(const QString& text);
|
||||||
|
void onModeChanged(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getMode(void) const;
|
|
||||||
double getLength(void) const;
|
double getLength(void) const;
|
||||||
double getLength2(void) const;
|
double getLength2(void) const;
|
||||||
|
double getOffset(void) const;
|
||||||
bool getReversed(void) const;
|
bool getReversed(void) const;
|
||||||
bool getMidplane(void) const;
|
bool getMidplane(void) const;
|
||||||
|
int getMode(void) const;
|
||||||
QString getFaceName(void) const;
|
QString getFaceName(void) const;
|
||||||
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||||
void updateUI(int index);
|
void updateUI(int index);
|
||||||
|
@ -100,7 +101,6 @@ public:
|
||||||
public:
|
public:
|
||||||
/// is called by the framework if the dialog is accepted (Ok)
|
/// is called by the framework if the dialog is accepted (Ok)
|
||||||
virtual bool accept();
|
virtual bool accept();
|
||||||
/// is called by the framework if the dialog is rejected (Cancel)
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TaskPadParameters *parameter;
|
TaskPadParameters *parameter;
|
||||||
|
|
|
@ -48,15 +48,6 @@
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
|
||||||
<double>999999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<double>5.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>10.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -71,20 +62,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="spinOffset">
|
<widget class="Gui::PrefQuantitySpinBox" name="offsetEdit"/>
|
||||||
<property name="minimum">
|
|
||||||
<double>0.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>999999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<double>5.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>0.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -119,15 +97,6 @@
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
|
||||||
<double>999999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<double>5.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>0.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
|
|
||||||
#include "ui_TaskPocketParameters.h"
|
#include "ui_TaskPocketParameters.h"
|
||||||
#include "TaskPocketParameters.h"
|
#include "TaskPocketParameters.h"
|
||||||
#include <Base/UnitsApi.h>
|
|
||||||
#include <App/Application.h>
|
#include <App/Application.h>
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
|
@ -54,7 +53,7 @@ using namespace Gui;
|
||||||
|
|
||||||
/* TRANSLATOR PartDesignGui::TaskPocketParameters */
|
/* TRANSLATOR PartDesignGui::TaskPocketParameters */
|
||||||
|
|
||||||
TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent)
|
TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent, bool newObj)
|
||||||
: TaskSketchBasedParameters(PocketView, parent, "PartDesign_Pocket",tr("Pocket parameters"))
|
: TaskSketchBasedParameters(PocketView, parent, "PartDesign_Pocket",tr("Pocket parameters"))
|
||||||
{
|
{
|
||||||
// we need a separate container widget to add all controls to
|
// we need a separate container widget to add all controls to
|
||||||
|
@ -64,10 +63,14 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
|
||||||
|
|
||||||
this->groupLayout()->addWidget(proxy);
|
this->groupLayout()->addWidget(proxy);
|
||||||
|
|
||||||
|
// set the history path
|
||||||
|
ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PocketLength"));
|
||||||
|
ui->offsetEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PocketOffset"));
|
||||||
|
|
||||||
// Get the feature data
|
// Get the feature data
|
||||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||||
double l = pcPocket->Length.getValue();
|
Base::Quantity l = pcPocket->Length.getQuantityValue();
|
||||||
double off = pcPocket->Offset.getValue();
|
Base::Quantity off = pcPocket->Offset.getQuantityValue();
|
||||||
bool midplane = pcPocket->Midplane.getValue();
|
bool midplane = pcPocket->Midplane.getValue();
|
||||||
bool reversed = pcPocket->Reversed.getValue();
|
bool reversed = pcPocket->Reversed.getValue();
|
||||||
int index = pcPocket->Type.getValue(); // must extract value here, clear() kills it!
|
int index = pcPocket->Type.getValue(); // must extract value here, clear() kills it!
|
||||||
|
@ -82,12 +85,8 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill data into dialog elements
|
// Fill data into dialog elements
|
||||||
ui->pocketLength->setMinimum(0);
|
ui->lengthEdit->setValue(l);
|
||||||
ui->pocketLength->setMaximum(INT_MAX);
|
ui->offsetEdit->setValue(off);
|
||||||
ui->pocketLength->setValue(l);
|
|
||||||
ui->spinOffset->setMinimum(-INT_MAX);
|
|
||||||
ui->spinOffset->setMaximum(INT_MAX);
|
|
||||||
ui->spinOffset->setValue(off);
|
|
||||||
ui->checkBoxMidplane->setChecked(midplane);
|
ui->checkBoxMidplane->setChecked(midplane);
|
||||||
ui->checkBoxReversed->setChecked(reversed);
|
ui->checkBoxReversed->setChecked(reversed);
|
||||||
if ((obj != NULL) && PartDesign::Feature::isDatum(obj))
|
if ((obj != NULL) && PartDesign::Feature::isDatum(obj))
|
||||||
|
@ -106,13 +105,13 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
|
||||||
ui->changeMode->setCurrentIndex(index);
|
ui->changeMode->setCurrentIndex(index);
|
||||||
|
|
||||||
// Bind input fields to properties
|
// Bind input fields to properties
|
||||||
ui->pocketLength->bind(pcPocket->Length);
|
ui->lengthEdit->bind(pcPocket->Length);
|
||||||
|
|
||||||
QMetaObject::connectSlotsByName(this);
|
QMetaObject::connectSlotsByName(this);
|
||||||
|
|
||||||
connect(ui->pocketLength, SIGNAL(valueChanged(double)),
|
connect(ui->lengthEdit, SIGNAL(valueChanged(double)),
|
||||||
this, SLOT(onLengthChanged(double)));
|
this, SLOT(onLengthChanged(double)));
|
||||||
connect(ui->spinOffset, SIGNAL(valueChanged(double)),
|
connect(ui->offsetEdit, SIGNAL(valueChanged(double)),
|
||||||
this, SLOT(onOffsetChanged(double)));
|
this, SLOT(onOffsetChanged(double)));
|
||||||
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
|
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(onMidplaneChanged(bool)));
|
this, SLOT(onMidplaneChanged(bool)));
|
||||||
|
@ -120,86 +119,82 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
|
||||||
this, SLOT(onReversedChanged(bool)));
|
this, SLOT(onReversedChanged(bool)));
|
||||||
connect(ui->changeMode, SIGNAL(currentIndexChanged(int)),
|
connect(ui->changeMode, SIGNAL(currentIndexChanged(int)),
|
||||||
this, SLOT(onModeChanged(int)));
|
this, SLOT(onModeChanged(int)));
|
||||||
connect(ui->buttonFace, SIGNAL(pressed()),
|
connect(ui->buttonFace, SIGNAL(clicked()),
|
||||||
this, SLOT(onButtonFace()));
|
this, SLOT(onButtonFace()));
|
||||||
connect(ui->lineFaceName, SIGNAL(textEdited(QString)),
|
connect(ui->lineFaceName, SIGNAL(textEdited(QString)),
|
||||||
this, SLOT(onFaceName(QString)));
|
this, SLOT(onFaceName(QString)));
|
||||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(onUpdateView(bool)));
|
this, SLOT(onUpdateView(bool)));
|
||||||
|
|
||||||
ui->checkBoxReversed->setVisible(true);
|
// Due to signals attached after changes took took into effect we should update the UI now.
|
||||||
|
|
||||||
updateUI(index);
|
updateUI(index);
|
||||||
|
|
||||||
//// check if the sketch has support
|
// if it is a newly created object use the last value of the history
|
||||||
//Sketcher::SketchObject *pcSketch;
|
if(newObj){
|
||||||
//if (pcPocket->Sketch.getValue()) {
|
ui->lengthEdit->setToLastUsedValue();
|
||||||
// pcSketch = static_cast<Sketcher::SketchObject*>(pcPocket->Sketch.getValue());
|
ui->lengthEdit->selectNumber();
|
||||||
// if (pcSketch->Support.getValue())
|
ui->offsetEdit->setToLastUsedValue();
|
||||||
// // in case of sketch with support, reverse makes no sense (goes into the part)
|
ui->offsetEdit->selectNumber();
|
||||||
// ui->checkBoxReversed->setEnabled(0);
|
}
|
||||||
// else
|
|
||||||
// ui->checkBoxReversed->setChecked(reversed);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPocketParameters::updateUI(int index)
|
void TaskPocketParameters::updateUI(int index)
|
||||||
{
|
{
|
||||||
if (index == 0) { // Only this option requires a numeric value // Dimension
|
// disable/hide evrything unless we are sure we don't need it
|
||||||
ui->pocketLength->setVisible(true);
|
bool isLengthEditVisable = false;
|
||||||
ui->pocketLength->setEnabled(true);
|
bool isOffsetEditVisable = false;
|
||||||
ui->pocketLength->selectAll();
|
bool isOffsetEditEnabled = true;
|
||||||
QMetaObject::invokeMethod(ui->pocketLength, "setFocus", Qt::QueuedConnection);
|
bool isMidplateEnabled = false;
|
||||||
ui->spinOffset->setVisible(false);
|
bool isReversedEnabled = false;
|
||||||
ui->spinOffset->setEnabled(false);
|
bool isFaceEditEnabled = false;
|
||||||
ui->spinOffset->setEnabled(false);
|
|
||||||
ui->checkBoxMidplane->setEnabled(true);
|
if (index == 0) { // dimension
|
||||||
|
isLengthEditVisable = true;
|
||||||
|
ui->lengthEdit->selectNumber();
|
||||||
|
// Make sure that the spin box has the focus to get key events
|
||||||
|
// Calling setFocus() directly doesn't work because the spin box is not
|
||||||
|
// yet visible.
|
||||||
|
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
|
||||||
|
isMidplateEnabled = true;
|
||||||
// Reverse only makes sense if Midplane is not true
|
// Reverse only makes sense if Midplane is not true
|
||||||
ui->checkBoxReversed->setEnabled(!ui->checkBoxMidplane->isChecked()); // Will flip direction of dimension
|
isReversedEnabled = !ui->checkBoxMidplane->isChecked();
|
||||||
ui->buttonFace->setEnabled(false);
|
} else if (index == 1) { // through all
|
||||||
ui->lineFaceName->setEnabled(false);
|
isOffsetEditVisable = true;
|
||||||
onButtonFace(false);
|
isOffsetEditEnabled = false; // offset may have some meaning for through all but it doesn't work
|
||||||
} else if (index == 1) { // Through all
|
isMidplateEnabled = true;
|
||||||
ui->checkBoxMidplane->setEnabled(true);
|
isReversedEnabled = !ui->checkBoxMidplane->isChecked();
|
||||||
ui->checkBoxReversed->setEnabled(!ui->checkBoxMidplane->isChecked()); // Will flip direction of through all
|
} else if (index == 2) { // up to first
|
||||||
ui->pocketLength->setVisible(false);
|
isOffsetEditVisable = true;
|
||||||
ui->pocketLength->setEnabled(false);
|
isReversedEnabled = true; // Will change the direction it seeks for its first face?
|
||||||
ui->spinOffset->setVisible(false);
|
// It may work not quite as expected but usefull if sketch oriented upside down.
|
||||||
ui->spinOffset->setVisible(false);
|
// (may happen in bodies)
|
||||||
ui->spinOffset->setEnabled(false);
|
// Fix probably lies somwhere in IF block on line 125 of FeaturePocket.cpp
|
||||||
ui->buttonFace->setEnabled(false);
|
} else if (index == 3) { // up to face
|
||||||
ui->lineFaceName->setEnabled(false);
|
isOffsetEditVisable = true;
|
||||||
onButtonFace(false);
|
isFaceEditEnabled = true;
|
||||||
} else if (index == 2) { // Neither value nor face required // To First
|
|
||||||
ui->pocketLength->setEnabled(false);
|
|
||||||
ui->pocketLength->setVisible(false);
|
|
||||||
ui->checkBoxMidplane->setEnabled(false); // Can't have a midplane to a single face
|
|
||||||
ui->checkBoxReversed->setEnabled(false); // Will change the direction it seeks for its first face?
|
|
||||||
// Doesnt work so is currently disabled. Fix probably lies
|
|
||||||
// somwhere in IF block on line 125 of FeaturePocket.cpp
|
|
||||||
ui->labelLength->setVisible(false);
|
|
||||||
ui->spinOffset->setVisible(true);
|
|
||||||
ui->spinOffset->setEnabled(true);
|
|
||||||
ui->labelOffset->setVisible(true);
|
|
||||||
ui->buttonFace->setEnabled(false);
|
|
||||||
ui->lineFaceName->setEnabled(false);
|
|
||||||
onButtonFace(false);
|
|
||||||
} else if (index == 3) { // Only this option requires to select a face // Up to face
|
|
||||||
ui->pocketLength->setEnabled(false);
|
|
||||||
ui->pocketLength->setVisible(false);
|
|
||||||
ui->labelLength->setVisible(false);
|
|
||||||
ui->spinOffset->setVisible(true);
|
|
||||||
ui->spinOffset->setEnabled(true);
|
|
||||||
ui->labelOffset->setVisible(true);
|
|
||||||
ui->checkBoxMidplane->setEnabled(false);
|
|
||||||
ui->checkBoxReversed->setEnabled(false); // No need for reverse since user-chosen face will dtermine direction
|
|
||||||
ui->buttonFace->setEnabled(true);
|
|
||||||
ui->lineFaceName->setEnabled(true);
|
|
||||||
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
|
||||||
// Go into reference selection mode if no face has been selected yet
|
// Go into reference selection mode if no face has been selected yet
|
||||||
if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected")))
|
if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected")))
|
||||||
onButtonFace(true);
|
onButtonFace(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->lengthEdit->setVisible( isLengthEditVisable );
|
||||||
|
ui->lengthEdit->setEnabled( isLengthEditVisable );
|
||||||
|
ui->labelLength->setVisible( isLengthEditVisable );
|
||||||
|
|
||||||
|
ui->offsetEdit->setVisible( isOffsetEditVisable );
|
||||||
|
ui->offsetEdit->setEnabled( isOffsetEditVisable && isOffsetEditEnabled );
|
||||||
|
ui->labelOffset->setVisible( isOffsetEditVisable );
|
||||||
|
|
||||||
|
ui->checkBoxMidplane->setEnabled( isMidplateEnabled );
|
||||||
|
|
||||||
|
ui->checkBoxReversed->setEnabled( isReversedEnabled );
|
||||||
|
|
||||||
|
ui->buttonFace->setEnabled( isFaceEditEnabled );
|
||||||
|
ui->lineFaceName->setEnabled( isFaceEditEnabled );
|
||||||
|
if (!isFaceEditEnabled) {
|
||||||
|
onButtonFace(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
|
@ -219,8 +214,7 @@ void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||||
ui->lineFaceName->blockSignals(false);
|
ui->lineFaceName->blockSignals(false);
|
||||||
}
|
}
|
||||||
}
|
} else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
|
||||||
else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
|
|
||||||
ui->lineFaceName->blockSignals(true);
|
ui->lineFaceName->blockSignals(true);
|
||||||
ui->lineFaceName->setText(tr("No face selected"));
|
ui->lineFaceName->setText(tr("No face selected"));
|
||||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||||
|
@ -264,11 +258,10 @@ void TaskPocketParameters::onModeChanged(int index)
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
// Why? See below for "UpToFace"
|
// Why? See below for "UpToFace"
|
||||||
pcPocket->Type.setValue("Length");
|
|
||||||
if (oldLength < Precision::Confusion())
|
if (oldLength < Precision::Confusion())
|
||||||
oldLength = 5.0;
|
oldLength = 5.0;
|
||||||
pcPocket->Length.setValue(oldLength);
|
pcPocket->Length.setValue(oldLength);
|
||||||
ui->pocketLength->setValue(oldLength);
|
ui->lengthEdit->setValue(oldLength);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
oldLength = pcPocket->Length.getValue();
|
oldLength = pcPocket->Length.getValue();
|
||||||
|
@ -284,10 +277,9 @@ void TaskPocketParameters::onModeChanged(int index)
|
||||||
oldLength = pcPocket->Length.getValue();
|
oldLength = pcPocket->Length.getValue();
|
||||||
pcPocket->Type.setValue("UpToFace");
|
pcPocket->Type.setValue("UpToFace");
|
||||||
pcPocket->Length.setValue(0.0);
|
pcPocket->Length.setValue(0.0);
|
||||||
ui->pocketLength->setValue(0.0);
|
ui->lengthEdit->setValue(0.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default: pcPocket->Type.setValue("Length"); break;
|
||||||
pcPocket->Type.setValue("Length");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUI(index);
|
updateUI(index);
|
||||||
|
@ -308,12 +300,12 @@ void TaskPocketParameters::onFaceName(const QString& text)
|
||||||
|
|
||||||
double TaskPocketParameters::getLength(void) const
|
double TaskPocketParameters::getLength(void) const
|
||||||
{
|
{
|
||||||
return ui->pocketLength->value().getValue();
|
return ui->lengthEdit->value().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
double TaskPocketParameters::getOffset(void) const
|
double TaskPocketParameters::getOffset(void) const
|
||||||
{
|
{
|
||||||
return ui->spinOffset->value();
|
return ui->offsetEdit->value().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskPocketParameters::getReversed(void) const
|
bool TaskPocketParameters::getReversed(void) const
|
||||||
|
@ -321,6 +313,11 @@ bool TaskPocketParameters::getReversed(void) const
|
||||||
return ui->checkBoxReversed->isChecked();
|
return ui->checkBoxReversed->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TaskPocketParameters::getMidplane(void) const
|
||||||
|
{
|
||||||
|
return ui->checkBoxMidplane->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
int TaskPocketParameters::getMode(void) const
|
int TaskPocketParameters::getMode(void) const
|
||||||
{
|
{
|
||||||
return ui->changeMode->currentIndex();
|
return ui->changeMode->currentIndex();
|
||||||
|
@ -347,8 +344,8 @@ void TaskPocketParameters::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
TaskBox::changeEvent(e);
|
TaskBox::changeEvent(e);
|
||||||
if (e->type() == QEvent::LanguageChange) {
|
if (e->type() == QEvent::LanguageChange) {
|
||||||
ui->pocketLength->blockSignals(true);
|
ui->lengthEdit->blockSignals(true);
|
||||||
ui->spinOffset->blockSignals(true);
|
ui->offsetEdit->blockSignals(true);
|
||||||
ui->lineFaceName->blockSignals(true);
|
ui->lineFaceName->blockSignals(true);
|
||||||
ui->changeMode->blockSignals(true);
|
ui->changeMode->blockSignals(true);
|
||||||
int index = ui->changeMode->currentIndex();
|
int index = ui->changeMode->currentIndex();
|
||||||
|
@ -367,31 +364,44 @@ void TaskPocketParameters::changeEvent(QEvent *e)
|
||||||
if (upToFace.indexOf("Face") == 0) {
|
if (upToFace.indexOf("Face") == 0) {
|
||||||
faceId = upToFace.remove(0,4).toInt(&ok);
|
faceId = upToFace.remove(0,4).toInt(&ok);
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= 0x040700
|
||||||
|
ui->lineFaceName->setPlaceholderText(tr("No face selected"));
|
||||||
|
#endif
|
||||||
ui->lineFaceName->setText(ok ?
|
ui->lineFaceName->setText(ok ?
|
||||||
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
|
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
|
||||||
tr("No face selected"));
|
tr(""));
|
||||||
ui->pocketLength->blockSignals(false);
|
ui->lengthEdit->blockSignals(false);
|
||||||
ui->spinOffset->blockSignals(false);
|
ui->offsetEdit->blockSignals(false);
|
||||||
ui->lineFaceName->blockSignals(false);
|
ui->lineFaceName->blockSignals(false);
|
||||||
ui->changeMode->blockSignals(false);
|
ui->changeMode->blockSignals(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskPocketParameters::saveHistory(void)
|
||||||
|
{
|
||||||
|
// save the user values to history
|
||||||
|
ui->lengthEdit->pushToHistory();
|
||||||
|
ui->offsetEdit->pushToHistory();
|
||||||
|
}
|
||||||
|
|
||||||
void TaskPocketParameters::apply()
|
void TaskPocketParameters::apply()
|
||||||
{
|
{
|
||||||
std::string name = vp->getObject()->getNameInDocument();
|
std::string name = vp->getObject()->getNameInDocument();
|
||||||
|
const char * cname = name.c_str();
|
||||||
|
|
||||||
//Gui::Command::openCommand("Pocket changed");
|
ui->lengthEdit->apply();
|
||||||
ui->pocketLength->apply();
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),getMode());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u", cname, getMode());
|
||||||
QString facename = getFaceName();
|
QString facename = getFaceName();
|
||||||
|
|
||||||
if (!facename.isEmpty()) {
|
if (!facename.isEmpty()) {
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s",
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s",
|
||||||
name.c_str(), facename.toLatin1().data() );
|
cname, facename.toLatin1().data());
|
||||||
} else
|
} else {
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", cname);
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i", name.c_str(), getReversed()?1:0);
|
}
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i", cname, getReversed()?1:0);
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i", cname, getMidplane()?1:0);
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Offset = %f", name.c_str(), getOffset());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Offset = %f", name.c_str(), getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,6 +430,9 @@ bool TaskDlgPocketParameters::accept()
|
||||||
{
|
{
|
||||||
parameter->apply();
|
parameter->apply();
|
||||||
|
|
||||||
|
// save the history
|
||||||
|
parameter->saveHistory();
|
||||||
|
|
||||||
return TaskDlgSketchBasedParameters::accept();
|
return TaskDlgSketchBasedParameters::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,34 +44,35 @@ class ViewProvider;
|
||||||
namespace PartDesignGui {
|
namespace PartDesignGui {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TaskPocketParameters : public TaskSketchBasedParameters
|
class TaskPocketParameters : public TaskSketchBasedParameters
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent = 0);
|
TaskPocketParameters(ViewProviderPocket *PocketView, QWidget *parent = 0, bool newObj=false);
|
||||||
~TaskPocketParameters();
|
~TaskPocketParameters();
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
|
void saveHistory(void);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onLengthChanged(double);
|
void onLengthChanged(double);
|
||||||
void onOffsetChanged(double);
|
void onOffsetChanged(double);
|
||||||
void onMidplaneChanged(bool);
|
void onMidplaneChanged(bool);
|
||||||
void onReversedChanged(bool);
|
void onReversedChanged(bool);
|
||||||
void onModeChanged(int);
|
|
||||||
void onButtonFace(const bool pressed = true);
|
void onButtonFace(const bool pressed = true);
|
||||||
void onFaceName(const QString& text);
|
void onFaceName(const QString& text);
|
||||||
|
void onModeChanged(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double getLength(void) const;
|
double getLength(void) const;
|
||||||
bool getMidplane(void) const;
|
|
||||||
int getMode(void) const;
|
|
||||||
double getOffset(void) const;
|
double getOffset(void) const;
|
||||||
|
int getMode(void) const;
|
||||||
|
bool getMidplane(void) const;
|
||||||
bool getReversed(void) const;
|
bool getReversed(void) const;
|
||||||
QString getFaceName(void) const;
|
QString getFaceName(void) const;
|
||||||
|
|
||||||
|
|
|
@ -10,18 +10,6 @@
|
||||||
<height>233</height>
|
<height>233</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>233</width>
|
|
||||||
<height>134</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -56,10 +44,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Gui::QuantitySpinBox" name="pocketLength">
|
<widget class="Gui::PrefQuantitySpinBox" name="lengthEdit">
|
||||||
<property name="unit" stdset="0">
|
|
||||||
<string notr="true">mm</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
@ -68,7 +53,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labelOffset">
|
<widget class="QLabel" name="labelOffset">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -77,11 +62,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="spinOffset">
|
<widget class="Gui::PrefQuantitySpinBox" name="offsetEdit"/>
|
||||||
<property name="maximum">
|
|
||||||
<double>999999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -97,9 +78,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBoxReversed">
|
<widget class="QCheckBox" name="checkBoxReversed">
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Reversed</string>
|
<string>Reversed</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -138,13 +116,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<resources/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>Gui::QuantitySpinBox</class>
|
<class>Gui::PrefQuantitySpinBox</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>Gui/QuantitySpinBox.h</header>
|
<header>Gui/PrefWidgets.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user