[TD] cleanup and fixes for Centerlines

- merge the flip Ends option to the main dialog
- use a QuantitySpinBox with angular unit for the angle
- store the state of the flipping correctly
- cleanup UI of dialog to avoid vertical whitespace
This commit is contained in:
donovaly
2020-03-19 02:57:25 +01:00
committed by WandererFan
parent c374a1213a
commit 00e5c48b3c
6 changed files with 526 additions and 666 deletions

View File

@@ -54,7 +54,6 @@
#include <Mod/TechDraw/App/Cosmetic.h>
#include <Mod/TechDraw/Gui/ui_TaskCenterLine.h>
#include <Mod/TechDraw/Gui/ui_TaskCL2Lines.h>
#include "DrawGuiStd.h"
#include "QGVPage.h"
@@ -80,7 +79,6 @@ TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
m_basePage(page),
m_createMode(false),
m_edgeName(edgeName),
m_flipped(false),
m_type(0), //0 - Face, 1 - 2 Lines, 2 - 2 points
m_mode(0) //0 - vertical, 1 - horizontal, 2 - aligned
@@ -97,7 +95,6 @@ TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
Base::Console().Message("TCL::TCL() - no centerline found\n");
}
m_type = m_cl->m_type;
m_flipped = m_cl->m_flip2Line;
m_mode = m_cl->m_mode;
setUiEdit();
@@ -112,7 +109,6 @@ TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
m_basePage(page),
m_createMode(true),
m_subNames(subNames),
m_flipped(false),
m_type(0), //0 - Face, 1 - 2 Lines, 2 - 2 points
m_mode(0) //0 - vertical, 1 - horizontal, 2 - aligned
{
@@ -161,7 +157,6 @@ void TaskCenterLine::changeEvent(QEvent *e)
void TaskCenterLine::setUiPrimary()
{
// Base::Console().Message("TCL::setUiPrimary()\n");
setWindowTitle(QObject::tr("Create Center Line"));
if (m_partFeat != nullptr) {
@@ -172,25 +167,32 @@ void TaskCenterLine::setUiPrimary()
ui->lstSubList->addItem(listItem);
}
}
ui->cpLineColor->setColor(getCenterColor());
ui->dsbWeight->setValue(getCenterWidth());
ui->cboxStyle->setCurrentIndex(getCenterStyle() - 1);
Base::Quantity qVal;
qVal.setUnit(Base::Unit::Length);
qVal.setValue(getExtendBy());
ui->qsbExtend->setValue(qVal);
Base::Quantity qAngle;
qAngle.setUnit(Base::Unit::Angle);
ui->qsbRotate->setValue(qAngle);
int precision = Base::UnitsApi::getDecimals();
ui->dsbRotate->setDecimals(precision);
ui->qsbRotate->setDecimals(precision);
if (m_type == 0) // if face, then aligned is not possible
ui->rbAligned->setEnabled(false);
else
ui->rbAligned->setEnabled(true);
if (m_type == 1) // only if line, feature is enabled
ui->cbFlip->setEnabled(true);
else
ui->cbFlip->setEnabled(false);
}
void TaskCenterLine::setUiEdit()
{
// Base::Console().Message("TCL::setUiEdit()\n");
setWindowTitle(QObject::tr("Edit Center Line"));
if (m_partFeat != nullptr) {
std::string baseName = m_partFeat->getNameInDocument();
@@ -198,25 +200,24 @@ void TaskCenterLine::setUiEdit()
QString listItem = Base::Tools::fromStdString(m_edgeName);
ui->lstSubList->addItem(listItem);
}
ui->cpLineColor->setColor(m_cl->m_format.m_color.asValue<QColor>());
ui->dsbWeight->setValue(m_cl->m_format.m_weight);
ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style - 1);
int precision = Base::UnitsApi::getDecimals();
ui->dsbRotate->setDecimals(precision);
ui->rbVertical->setChecked(false);
ui->rbHorizontal->setChecked(false);
ui->rbAligned->setChecked(false);
if (m_cl->m_mode == 0) {
if (m_cl->m_mode == 0)
ui->rbVertical->setChecked(true);
} else if (m_cl->m_mode == 1) {
else if (m_cl->m_mode == 1)
ui->rbHorizontal->setChecked(true);
} else if (m_cl->m_mode ==2) {
else if (m_cl->m_mode ==2)
ui->rbAligned->setChecked(true);
}
ui->dsbRotate->setValue(m_cl->m_rotate);
if (m_cl->m_type == 0) // if face, then aligned is not possible
ui->rbAligned->setEnabled(false);
else
ui->rbAligned->setEnabled(true);
Base::Quantity qVal;
qVal.setUnit(Base::Unit::Length);
qVal.setValue(m_cl->m_vShift);
@@ -225,10 +226,22 @@ void TaskCenterLine::setUiEdit()
ui->qsbHorizShift->setValue(qVal);
qVal.setValue(m_cl->m_extendBy);
ui->qsbExtend->setValue(qVal);
if (m_cl->m_type == 0) // if face, then aligned is not possible
ui->rbAligned->setEnabled(false);
Base::Quantity qAngle;
qAngle.setUnit(Base::Unit::Angle);
ui->qsbRotate->setValue(qAngle);
int precision = Base::UnitsApi::getDecimals();
ui->qsbRotate->setDecimals(precision);
ui->qsbRotate->setValue(m_cl->m_rotate);
if (m_cl->m_flip2Line)
ui->cbFlip->setChecked(true);
else
ui->rbAligned->setEnabled(true);
ui->cbFlip->setChecked(false);
if (m_cl->m_type == 1) // only if line, feature is enabled
ui->cbFlip->setEnabled(true);
else
ui->cbFlip->setEnabled(false);
}
//******************************************************************************
@@ -239,7 +252,7 @@ void TaskCenterLine::createCenterLine(void)
// bool vertical = false;
double hShift = ui->qsbHorizShift->rawValue();
double vShift = ui->qsbVertShift->rawValue();
double rotate = ui->dsbRotate->value();
double rotate = ui->qsbRotate->rawValue();
double extendBy = ui->qsbExtend->rawValue();
std::pair<Base::Vector3d, Base::Vector3d> ends;
if (ui->rbVertical->isChecked()) {
@@ -253,13 +266,12 @@ void TaskCenterLine::createCenterLine(void)
TechDraw::CenterLine* cl = CenterLine::CenterLineBuilder(m_partFeat,
m_subNames,
m_mode,
m_flipped);
m_mode);
if (cl != nullptr) {
cl->setShifts(hShift, vShift);
cl->setExtend(extendBy);
cl->setRotate(rotate);
cl->setFlip(m_flipped);
cl->m_flip2Line = ui->cbFlip->checkState();
App::Color ac;
ac.setValue<QColor>(ui->cpLineColor->color());
cl->m_format.m_color = ac;
@@ -293,12 +305,12 @@ void TaskCenterLine::updateCenterLine(void)
m_mode = CenterLine::CLMODE::ALIGNED;
}
m_cl->m_mode = m_mode;
m_cl->m_rotate = ui->dsbRotate->value();
m_cl->m_rotate = ui->qsbRotate->rawValue();
m_cl->m_vShift = ui->qsbVertShift->rawValue();
m_cl->m_hShift = ui->qsbHorizShift->rawValue();
m_cl->m_extendBy = ui->qsbExtend->rawValue();
m_cl->m_type = m_type;
m_cl->m_flip2Line = m_flipped;
m_cl->m_flip2Line = ui->cbFlip->checkState();
m_partFeat->replaceCenterLine(m_cl);
m_partFeat->refreshCLGeoms();
m_partFeat->requestPaint();
@@ -361,12 +373,6 @@ double TaskCenterLine::getExtendBy(void)
return ext;
}
void TaskCenterLine::setFlipped(bool b)
{
// Base::Console().Message("TCL::setFlipped(%d)\n",b);
m_flipped = b;
}
//******************************************************************************
bool TaskCenterLine::accept()
@@ -408,51 +414,6 @@ bool TaskCenterLine::reject()
return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskCL2Lines::TaskCL2Lines(TechDrawGui::TaskCenterLine* tcl) :
ui(new Ui_TaskCL2Lines),
m_tcl(tcl)
{
ui->setupUi(this);
connect(ui->cbFlip, SIGNAL(toggled( bool )), this, SLOT(onFlipToggled( bool )));
initUi();
}
TaskCL2Lines::~TaskCL2Lines()
{
delete ui;
}
void TaskCL2Lines::initUi()
{
}
void TaskCL2Lines::onFlipToggled(bool b)
{
// Base::Console().Message("TCL2L::onFlipToggled(%d)\n", b);
m_tcl->setFlipped(b);
}
bool TaskCL2Lines::accept()
{
// Base::Console().Message("TCL2L::accept()\n");
return true;
}
bool TaskCL2Lines::reject()
{
// Base::Console().Message("TCL2L::reject()\n");
return false;
}
void TaskCL2Lines::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -466,18 +427,6 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat,
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
cl2Lines = new TaskCL2Lines(widget);
linesBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-2linecenterline"),
cl2Lines->windowTitle(), true, 0);
linesBox->groupLayout()->addWidget(cl2Lines);
Content.push_back(linesBox);
// cl2Points = new TaskCL2Points(widget);
// pointsBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-2pointcenterline"),
// widget->windowTitle(), true, 0);
// pointsBox->groupLayout()->addWidget(cl2Lines);
// Content.push_back(pointsBox);
}
TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat,
@@ -490,18 +439,6 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat,
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
cl2Lines = new TaskCL2Lines(widget);
linesBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-2linecenterline"),
widget->windowTitle(), true, 0);
linesBox->groupLayout()->addWidget(cl2Lines);
Content.push_back(linesBox);
// cl2Points = new TaskCL2Points(widget);
// pointsBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-2pointcenterline"),
// widget->windowTitle(), true, 0);
// pointsBox->groupLayout()->addWidget(cl2Lines);
// Content.push_back(pointsBox);
}
TaskDlgCenterLine::~TaskDlgCenterLine()