[TD] Centerline dialog refurbish

- group the radio buttons
- make edit dialog apply immediately
This commit is contained in:
donovaly
2020-03-22 23:11:10 +01:00
committed by WandererFan
parent bf4e6b6316
commit 28e40f8dc5
3 changed files with 171 additions and 52 deletions

View File

@@ -29,6 +29,7 @@
#endif // #ifndef _PreComp_
#include <QButtonGroup>
#include <QStatusBar>
#include <QGraphicsScene>
@@ -133,6 +134,7 @@ TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
Base::Console().Error("TaskCenterLine - unknown geometry type: %s. Can not proceed.\n", geomType.c_str());
return;
}
setUiPrimary();
}
@@ -181,6 +183,7 @@ void TaskCenterLine::setUiPrimary()
ui->qsbRotate->setValue(qAngle);
int precision = Base::UnitsApi::getDecimals();
ui->qsbRotate->setDecimals(precision);
if (m_type == 0) // if face, then aligned is not possible
ui->rbAligned->setEnabled(false);
else
@@ -202,8 +205,11 @@ void TaskCenterLine::setUiEdit()
ui->lstSubList->addItem(listItem);
}
ui->cpLineColor->setColor(m_cl->m_format.m_color.asValue<QColor>());
connect(ui->cpLineColor, SIGNAL(changed()), this, SLOT(onColorChanged()));
ui->dsbWeight->setValue(m_cl->m_format.m_weight);
connect(ui->dsbWeight, SIGNAL(valueChanged(double)), this, SLOT(onWeightChanged()));
ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style - 1);
connect(ui->cboxStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(onStyleChanged()));
ui->rbVertical->setChecked(false);
ui->rbHorizontal->setChecked(false);
@@ -223,10 +229,13 @@ void TaskCenterLine::setUiEdit()
qVal.setUnit(Base::Unit::Length);
qVal.setValue(m_cl->m_vShift);
ui->qsbVertShift->setValue(qVal);
connect(ui->qsbVertShift, SIGNAL(valueChanged(double)), this, SLOT(onShiftVertChanged()));
qVal.setValue(m_cl->m_hShift);
ui->qsbHorizShift->setValue(qVal);
connect(ui->qsbHorizShift, SIGNAL(valueChanged(double)), this, SLOT(onShiftHorizChanged()));
qVal.setValue(m_cl->m_extendBy);
ui->qsbExtend->setValue(qVal);
connect(ui->qsbExtend, SIGNAL(valueChanged(double)), this, SLOT(onExtendChanged()));
Base::Quantity qAngle;
qAngle.setUnit(Base::Unit::Angle);
@@ -234,6 +243,7 @@ void TaskCenterLine::setUiEdit()
int precision = Base::UnitsApi::getDecimals();
ui->qsbRotate->setDecimals(precision);
ui->qsbRotate->setValue(m_cl->m_rotate);
connect(ui->qsbRotate, SIGNAL(valueChanged(double)), this, SLOT(onRotationChanged()));
if (m_cl->m_flip2Line)
ui->cbFlip->setChecked(true);
@@ -244,8 +254,74 @@ void TaskCenterLine::setUiEdit()
ui->cbFlip->setEnabled(true);
else
ui->cbFlip->setEnabled(false);
connect(ui->cbFlip, SIGNAL(toggled(bool)), this, SLOT(onFlipChanged()));
// connect the Orientation radio group box
connect(ui->bgOrientation, SIGNAL(buttonClicked(int)), this, SLOT(onOrientationChanged()));
}
void TaskCenterLine::onOrientationChanged()
{
if (ui->rbVertical->isChecked())
m_cl->m_mode = CenterLine::CLMODE::VERTICAL;
else if (ui->rbHorizontal->isChecked())
m_cl->m_mode = CenterLine::CLMODE::HORIZONTAL;
else if (ui->rbAligned->isChecked())
m_cl->m_mode = CenterLine::CLMODE::ALIGNED;
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onShiftHorizChanged()
{
m_cl->m_hShift = ui->qsbHorizShift->rawValue();
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onShiftVertChanged()
{
m_cl->m_vShift = ui->qsbVertShift->rawValue();
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onRotationChanged()
{
m_cl->m_rotate = ui->qsbRotate->rawValue();
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onExtendChanged()
{
m_cl->m_extendBy = ui->qsbExtend->rawValue();
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onColorChanged()
{
App::Color ac;
ac.setValue<QColor>(ui->cpLineColor->color());
m_cl->m_format.m_color.setValue<QColor>(ui->cpLineColor->color());
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onWeightChanged()
{
m_cl->m_format.m_weight = ui->dsbWeight->value();
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onStyleChanged()
{
m_cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1;
m_partFeat->recomputeFeature();
}
void TaskCenterLine::onFlipChanged()
{
m_cl->m_flip2Line = ui->cbFlip->isChecked();
m_partFeat->recomputeFeature();
}
//******************************************************************************
void TaskCenterLine::createCenterLine(void)
{

View File

@@ -94,7 +94,6 @@ public:
void enableTaskButtons(bool b);
void setFlipped(bool b);
protected Q_SLOTS:
protected:
@@ -117,6 +116,17 @@ protected:
Qt::PenStyle getCenterStyle();
double getExtendBy();
private Q_SLOTS:
void onOrientationChanged();
void onShiftHorizChanged();
void onShiftVertChanged();
void onRotationChanged();
void onExtendChanged();
void onColorChanged();
void onWeightChanged();
void onStyleChanged();
void onFlipChanged();
private:
Ui_TaskCenterLine * ui;

View File

@@ -2,16 +2,19 @@
<ui version="4.0">
<class>TechDrawGui::TaskCenterLine</class>
<widget class="QWidget" name="TechDrawGui::TaskCenterLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>393</height>
<height>374</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<sizepolicy hsizetype="Fixed" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -32,6 +35,13 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Base View</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leBaseView">
<property name="enabled">
@@ -48,13 +58,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Base View</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -67,10 +70,16 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
<height>50</height>
</size>
</property>
</widget>
@@ -78,50 +87,67 @@
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QRadioButton" name="rbVertical">
<property name="toolTip">
<string>Top to Bottom line</string>
</property>
<property name="text">
<string>Vertical</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="rbHorizontal">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Left to Right line</string>
</property>
<property name="text">
<string>Horizontal</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="rbAligned">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>centerline between
<widget class="QGroupBox" name="gbOrientation">
<property name="toolTip">
<string/>
</property>
<property name="title">
<string>Orientation</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="rbVertical">
<property name="toolTip">
<string>Top to Bottom line</string>
</property>
<property name="text">
<string>Vertical</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bgOrientation</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbHorizontal">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Left to Right line</string>
</property>
<property name="text">
<string>Horizontal</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bgOrientation</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbAligned">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>centerline between
- lines: in equal distance to the lines and with
half of the angle the lines have to each other
- points: in equal distance to the points</string>
</property>
<property name="text">
<string>Aligned</string>
</property>
</widget>
</item>
</layout>
</property>
<property name="text">
<string>Aligned</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bgOrientation</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,3,0,3">
@@ -359,4 +385,11 @@ see the FreeCAD Wiki '2LineCenterLine' for a description</string>
<include location="Resources/TechDraw.qrc"/>
</resources>
<connections/>
<buttongroups>
<buttongroup name="bgOrientation">
<property name="exclusive">
<bool>true</bool>
</property>
</buttongroup>
</buttongroups>
</ui>