[TD] Section dialog overhaul
- replace use uniformly Gui::QuantitySpinBox - fix and uniform size of all objects in the dialog - apply changes immediately once the section is created because this speeds up the workflow a lot, especially for when changing the plane position - some code cleanup: remove unused void, avoid unused variables
This commit is contained in:
@@ -94,19 +94,12 @@ TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base) :
|
||||
m_saveBaseName = m_base->getNameInDocument();
|
||||
m_savePageName = m_base->findParentPage()->getNameInDocument();
|
||||
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->pbUp, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onUpClicked(bool)));
|
||||
connect(ui->pbDown, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onDownClicked(bool)));
|
||||
connect(ui->pbRight, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onRightClicked(bool)));
|
||||
connect(ui->pbLeft, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onLeftClicked(bool)));
|
||||
connect(ui->pbApply, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onApplyClicked(bool)));
|
||||
connect(ui->pbUp, SIGNAL(clicked(bool)), this, SLOT(onUpClicked()));
|
||||
connect(ui->pbDown, SIGNAL(clicked(bool)), this, SLOT(onDownClicked()));
|
||||
connect(ui->pbRight, SIGNAL(clicked(bool)), this, SLOT(onRightClicked()));
|
||||
connect(ui->pbLeft, SIGNAL(clicked(bool)), this, SLOT(onLeftClicked()));
|
||||
|
||||
setUiPrimary();
|
||||
}
|
||||
@@ -143,16 +136,10 @@ TaskSectionView::TaskSectionView(TechDraw::DrawViewSection* section) :
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->pbUp, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onUpClicked(bool)));
|
||||
connect(ui->pbDown, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onDownClicked(bool)));
|
||||
connect(ui->pbRight, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onRightClicked(bool)));
|
||||
connect(ui->pbLeft, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onLeftClicked(bool)));
|
||||
connect(ui->pbApply, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onApplyClicked(bool)));
|
||||
connect(ui->pbUp, SIGNAL(clicked(bool)), this, SLOT(onUpClicked()));
|
||||
connect(ui->pbDown, SIGNAL(clicked(bool)), this, SLOT(onDownClicked()));
|
||||
connect(ui->pbRight, SIGNAL(clicked(bool)), this, SLOT(onRightClicked()));
|
||||
connect(ui->pbLeft, SIGNAL(clicked(bool)), this, SLOT(onLeftClicked()));
|
||||
|
||||
m_dirName = m_section->SectionDirection.getValueAsString();
|
||||
saveSectionState();
|
||||
@@ -180,6 +167,18 @@ void TaskSectionView::setUiPrimary()
|
||||
ui->sbOrgX->setValue(origin.x);
|
||||
ui->sbOrgY->setValue(origin.y);
|
||||
ui->sbOrgZ->setValue(origin.z);
|
||||
|
||||
// before the user did not select an orientation,
|
||||
// the section properties cannot be changed
|
||||
this->setToolTip(QObject::tr("Select at first an orientation"));
|
||||
enableAll(false);
|
||||
|
||||
// now connect and not earlier to avoid premature apply() calls
|
||||
connect(ui->leSymbol, SIGNAL(textChanged(QString)), this, SLOT(onIdentifierChanged()));
|
||||
connect(ui->sbScale, SIGNAL(valueChanged(double)), this, SLOT(onScaleChanged()));
|
||||
connect(ui->sbOrgX, SIGNAL(valueChanged(double)), this, SLOT(onXChanged()));
|
||||
connect(ui->sbOrgY, SIGNAL(valueChanged(double)), this, SLOT(onYChanged()));
|
||||
connect(ui->sbOrgZ, SIGNAL(valueChanged(double)), this, SLOT(onZChanged()));
|
||||
}
|
||||
|
||||
void TaskSectionView::setUiEdit()
|
||||
@@ -200,6 +199,13 @@ void TaskSectionView::setUiEdit()
|
||||
ui->sbOrgX->setValue(origin.x);
|
||||
ui->sbOrgY->setValue(origin.y);
|
||||
ui->sbOrgZ->setValue(origin.z);
|
||||
|
||||
// connect affter initializing the object values
|
||||
connect(ui->leSymbol, SIGNAL(textChanged(QString)), this, SLOT(onIdentifierChanged()));
|
||||
connect(ui->sbScale, SIGNAL(valueChanged(double)), this, SLOT(onScaleChanged()));
|
||||
connect(ui->sbOrgX, SIGNAL(valueChanged(double)), this, SLOT(onXChanged()));
|
||||
connect(ui->sbOrgY, SIGNAL(valueChanged(double)), this, SLOT(onYChanged()));
|
||||
connect(ui->sbOrgZ, SIGNAL(valueChanged(double)), this, SLOT(onZChanged()));
|
||||
}
|
||||
|
||||
//save the start conditions
|
||||
@@ -231,51 +237,64 @@ void TaskSectionView::restoreSectionState()
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSectionView::blockButtons(bool b)
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
}
|
||||
|
||||
void TaskSectionView::onUpClicked(bool b)
|
||||
void TaskSectionView::onUpClicked()
|
||||
{
|
||||
// Base::Console().Message("TSV::onUpClicked()\n");
|
||||
Q_UNUSED(b);
|
||||
checkAll(false);
|
||||
ui->pbUp->setChecked(true);
|
||||
applyQuick("Up");
|
||||
}
|
||||
|
||||
void TaskSectionView::onDownClicked(bool b)
|
||||
void TaskSectionView::onDownClicked()
|
||||
{
|
||||
// Base::Console().Message("TSV::onDownClicked()\n");
|
||||
Q_UNUSED(b);
|
||||
checkAll(false);
|
||||
ui->pbDown->setChecked(true);
|
||||
applyQuick("Down");
|
||||
}
|
||||
|
||||
void TaskSectionView::onLeftClicked(bool b)
|
||||
void TaskSectionView::onLeftClicked()
|
||||
{
|
||||
// Base::Console().Message("TSV::onLeftClicked()\n");
|
||||
checkAll(false);
|
||||
ui->pbLeft->setChecked(true);
|
||||
Q_UNUSED(b);
|
||||
applyQuick("Left");
|
||||
}
|
||||
|
||||
void TaskSectionView::onRightClicked(bool b)
|
||||
void TaskSectionView::onRightClicked()
|
||||
{
|
||||
// Base::Console().Message("TSV::onRightClicked()\n");
|
||||
Q_UNUSED(b);
|
||||
checkAll(false);
|
||||
ui->pbRight->setChecked(true);
|
||||
applyQuick("Right");
|
||||
}
|
||||
|
||||
void TaskSectionView::onApplyClicked(bool b)
|
||||
void TaskSectionView::onIdentifierChanged()
|
||||
{
|
||||
checkAll(false);
|
||||
apply();
|
||||
}
|
||||
|
||||
void TaskSectionView::onScaleChanged()
|
||||
{
|
||||
checkAll(false);
|
||||
apply();
|
||||
}
|
||||
|
||||
void TaskSectionView::onXChanged()
|
||||
{
|
||||
checkAll(false);
|
||||
apply();
|
||||
}
|
||||
|
||||
void TaskSectionView::onYChanged()
|
||||
{
|
||||
checkAll(false);
|
||||
apply();
|
||||
}
|
||||
|
||||
void TaskSectionView::onZChanged()
|
||||
{
|
||||
// Base::Console().Message("TSV::onApplyClicked()\n");
|
||||
Q_UNUSED(b);
|
||||
checkAll(false);
|
||||
apply();
|
||||
}
|
||||
@@ -288,13 +307,22 @@ void TaskSectionView::checkAll(bool b)
|
||||
ui->pbLeft->setChecked(b);
|
||||
}
|
||||
|
||||
void TaskSectionView::enableAll(bool b)
|
||||
{
|
||||
ui->leSymbol->setEnabled(b);
|
||||
ui->sbScale->setEnabled(b);
|
||||
ui->sbOrgX->setEnabled(b);
|
||||
ui->sbOrgY->setEnabled(b);
|
||||
ui->sbOrgZ->setEnabled(b);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
bool TaskSectionView::apply(void)
|
||||
{
|
||||
// Base::Console().Message("TSV::apply() - m_dirName: %s\n", m_dirName.c_str());
|
||||
if (m_dirName.empty()) {
|
||||
std::string msg =
|
||||
Base::Tools::toStdString(tr("TSV::apply - Nothing to apply. No section direction picked yet"));
|
||||
Base::Tools::toStdString(tr("Nothing to apply. No section direction picked yet"));
|
||||
Base::Console().Error((msg + "\n").c_str());
|
||||
return false;
|
||||
}
|
||||
@@ -318,6 +346,11 @@ void TaskSectionView::applyQuick(std::string dir)
|
||||
if (isSectionValid()) {
|
||||
updateSectionView();
|
||||
m_section->recomputeFeature();
|
||||
this->setToolTip(QObject::tr("Select at first an orientation"));
|
||||
// we can in any case enable all objects in the dialog
|
||||
// and remove the dialog-wide tooltip if there was one
|
||||
enableAll(true);
|
||||
this->setToolTip(QString());
|
||||
} else {
|
||||
failNoObject(m_sectionName);
|
||||
}
|
||||
@@ -420,7 +453,7 @@ void TaskSectionView::updateSectionView(void)
|
||||
lblText.c_str());
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.Scale = %0.6f",
|
||||
m_sectionName.c_str(),
|
||||
ui->sbScale->value());
|
||||
ui->sbScale->value().getValue());
|
||||
m_section->setCSFromBase(m_dirName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user