Skip to content

Commit

Permalink
[TD] cleanup and fixes for Centerlines
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
donovaly authored and WandererFan committed Mar 19, 2020
1 parent e98a214 commit f9c9d1e
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 666 deletions.
3 changes: 0 additions & 3 deletions src/Mod/TechDraw/Gui/CMakeLists.txt
Expand Up @@ -98,7 +98,6 @@ set(TechDrawGui_UIC_SRCS
TaskBalloon.ui
TaskCosVertex.ui
TaskCenterLine.ui
TaskCL2Lines.ui
TaskLineDecor.ui
TaskRestoreLines.ui
TaskWeldingSymbol.ui
Expand Down Expand Up @@ -189,7 +188,6 @@ SET(TechDrawGui_SRCS
TaskLineDecor.cpp
TaskLineDecor.h
TaskRestoreLines.ui
TaskCL2Lines.ui
TaskWeldingSymbol.ui
TaskWeldingSymbol.cpp
TaskWeldingSymbol.h
Expand Down Expand Up @@ -365,7 +363,6 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskCenterLine.ui
TaskLineDecor.ui
TaskRestoreLines.ui
TaskCL2Lines.ui
TaskWeldingSymbol.ui
SymbolChooser.ui
TaskActiveView.ui
Expand Down
38 changes: 0 additions & 38 deletions src/Mod/TechDraw/Gui/TaskCL2Lines.ui

This file was deleted.

139 changes: 38 additions & 101 deletions src/Mod/TechDraw/Gui/TaskCenterLine.cpp
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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();
Expand All @@ -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
{
Expand Down Expand Up @@ -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) {
Expand All @@ -172,51 +167,57 @@ 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();
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
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);
Expand All @@ -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);
}

//******************************************************************************
Expand All @@ -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()) {
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -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,
Expand All @@ -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()
Expand Down

0 comments on commit f9c9d1e

Please sign in to comment.