[TD]Remove NoLine option from dialogs

This commit is contained in:
wandererfan
2019-07-17 13:17:45 -04:00
committed by WandererFan
parent c29a84b308
commit 12a35a0955
5 changed files with 60 additions and 44 deletions

View File

@@ -175,7 +175,7 @@ void TaskCenterLine::setUiPrimary()
ui->cpLineColor->setColor(getCenterColor());
ui->dsbWeight->setValue(getCenterWidth());
ui->cboxStyle->setCurrentIndex(getCenterStyle());
ui->cboxStyle->setCurrentIndex(getCenterStyle() - 1);
Base::Quantity qVal;
qVal.setUnit(Base::Unit::Length);
qVal.setValue(getExtendBy());
@@ -197,7 +197,7 @@ void TaskCenterLine::setUiEdit()
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);
ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style - 1);
int precision = Base::UnitsApi::getDecimals();
ui->dsbRotate->setDecimals(precision);
@@ -271,7 +271,7 @@ void TaskCenterLine::createCenterLine(void)
ac.setValue<QColor>(ui->cpLineColor->color());
cl->m_format.m_color = ac;
cl->m_format.m_weight = ui->dsbWeight->value();
cl->m_format.m_style = ui->cboxStyle->currentIndex();
cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1; //Qt Styles start at 0:NoLine
cl->m_format.m_visible = true;
if (m_type == 0) {
@@ -305,7 +305,7 @@ void TaskCenterLine::updateCenterLine(void)
Gui::Command::openCommand("Edit CenterLine");
m_cl->m_format.m_color.setValue<QColor>(ui->cpLineColor->color() );
m_cl->m_format.m_weight = ui->dsbWeight->value();
m_cl->m_format.m_style = ui->cboxStyle->currentIndex();
m_cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1;
m_cl->m_format.m_visible = true;
if (ui->rbVertical->isChecked()) {
@@ -316,21 +316,14 @@ void TaskCenterLine::updateCenterLine(void)
m_mode =2;
}
m_cl->m_mode = m_mode;
// if (ui->rbVertical->isChecked()) {
// m_cl->m_mode = 0;
// } else if (ui->rbHorizontal->isChecked()) {
// m_cl->m_mode = 1;
// } else if (ui->rbAligned->isChecked()) {
// m_cl->m_mode = 2;
// }
m_cl->m_rotate = ui->dsbRotate->value();
m_cl->m_vShift = ui->qsbVertShift->rawValue();
m_cl->m_hShift = ui->qsbHorizShift->rawValue();
m_cl->m_extendBy = ui->qsbExtend->rawValue();
m_partFeat->replaceCenterLine(m_clIdx, m_cl);
m_partFeat->requestPaint();
m_cl->m_type = m_type;
m_cl->m_flip2Line = m_flipped;
m_partFeat->replaceCenterLine(m_clIdx, m_cl);
m_partFeat->requestPaint();
Gui::Command::updateActive();
Gui::Command::commitCommand();
@@ -358,6 +351,11 @@ double TaskCenterLine::getCenterWidth()
double width = lg->getWeight("Graphic");
delete lg;
Gui::ViewProvider* vp = QGIView::getViewProvider(m_partFeat);
auto partVP = dynamic_cast<ViewProviderViewPart*>(vp);
if ( vp != nullptr ) {
width = partVP->IsoWidth.getValue();
}
return width;
}

View File

@@ -252,13 +252,8 @@
<item row="4" column="1">
<widget class="QComboBox" name="cboxStyle">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<item>
<property name="text">
<string>NoLine</string>
</property>
</item>
<item>
<property name="text">
<string>Solid</string>

View File

@@ -51,6 +51,8 @@
#include <Mod/TechDraw/Gui/ui_TaskLineDecor.h>
#include <Mod/TechDraw/Gui/ui_TaskRestoreLines.h>
#include "QGIView.h"
#include "ViewProviderViewPart.h"
#include "TaskLineDecor.h"
using namespace Gui;
@@ -61,7 +63,8 @@ TaskLineDecor::TaskLineDecor(TechDraw::DrawViewPart* partFeat,
std::vector<std::string> edgeNames) :
ui(new Ui_TaskLineDecor),
m_partFeat(partFeat),
m_edges(edgeNames)
m_edges(edgeNames),
m_apply(true)
{
getDefaults();
ui->setupUi(this);
@@ -95,7 +98,7 @@ void TaskLineDecor::initUi()
}
ui->le_Lines->setText(Base::Tools::fromStdString(temp));
ui->cb_Style->setCurrentIndex(m_style);
ui->cb_Style->setCurrentIndex(m_style - 1); //combobox does not have 0:NoLine choice
ui->cc_Color->setColor(m_color.asValue<QColor>());
ui->dsb_Weight->setValue(m_weight);
ui->cb_Visible->setCurrentIndex(m_visible);
@@ -103,6 +106,7 @@ void TaskLineDecor::initUi()
void TaskLineDecor::getDefaults(void)
{
// Base::Console().Message("TLD::getDefaults()\n");
m_style = LineFormat::getDefEdgeStyle();
m_color = LineFormat::getDefEdgeColor();
m_weight = LineFormat::getDefEdgeWidth();
@@ -128,13 +132,22 @@ void TaskLineDecor::getDefaults(void)
m_visible = cl->m_format.m_visible;
}
} else {
TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatByGeom(num);
if (gf != nullptr) {
m_style = gf->m_format.m_style;
m_color = gf->m_format.m_color;
m_weight = gf->m_format.m_weight;
m_visible = gf->m_format.m_visible;
TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatByGeom(num);
if (gf != nullptr) {
m_style = gf->m_format.m_style;
m_color = gf->m_format.m_color;
m_weight = gf->m_format.m_weight;
m_visible = gf->m_format.m_visible;
} else {
Gui::ViewProvider* vp = QGIView::getViewProvider(m_partFeat);
auto partVP = dynamic_cast<ViewProviderViewPart*>(vp);
if ( vp != nullptr ) {
m_weight = partVP->LineWidth.getValue();
m_style = Qt::SolidLine; // = 1
m_color = LineFormat::getDefEdgeColor();
m_visible = 1;
}
}
}
}
}
@@ -142,7 +155,7 @@ void TaskLineDecor::getDefaults(void)
void TaskLineDecor::onStyleChanged(void)
{
m_style = ui->cb_Style->currentIndex();
m_style = ui->cb_Style->currentIndex() + 1;
//livePreview();
}
@@ -214,7 +227,9 @@ bool TaskLineDecor::accept()
Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument());
if (!doc) return false;
applyDecorations();
if (apply()) {
applyDecorations();
}
m_partFeat->requestPaint();
@@ -241,9 +256,11 @@ void TaskLineDecor::changeEvent(QEvent *e)
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskRestoreLines::TaskRestoreLines(TechDraw::DrawViewPart* partFeat) :
TaskRestoreLines::TaskRestoreLines(TechDraw::DrawViewPart* partFeat,
TaskLineDecor* parent) :
ui(new Ui_TaskRestoreLines),
m_partFeat(partFeat)
m_partFeat(partFeat),
m_parent(parent)
{
ui->setupUi(this);
@@ -361,6 +378,7 @@ void TaskRestoreLines::restoreInvisibleGeoms(void)
}
}
m_partFeat->GeomFormats.setValues(geoms);
m_parent->apply(false); //don't undo the work we just did
}
void TaskRestoreLines::restoreInvisibleCosmetics(void)
@@ -372,6 +390,7 @@ void TaskRestoreLines::restoreInvisibleCosmetics(void)
}
}
m_partFeat->CosmeticEdges.setValues(cosmos);
m_parent->apply(false); //don't undo the work we just did
}
void TaskRestoreLines::restoreInvisibleCenters(void)
@@ -383,6 +402,7 @@ void TaskRestoreLines::restoreInvisibleCenters(void)
}
}
m_partFeat->CenterLines.setValues(centers);
m_parent->apply(false); //don't undo the work we just did
}
@@ -418,12 +438,15 @@ TaskDlgLineDecor::TaskDlgLineDecor(TechDraw::DrawViewPart* partFeat,
if (edgeNames.empty()) {
taskbox->hideGroupBox();
}
restore = new TaskRestoreLines(partFeat);
restoreBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-linedecor"),
tr("Restore Invisible Lines"), true, 0);
restoreBox->groupLayout()->addWidget(restore);
Content.push_back(restoreBox);
TaskLineDecor* parent = dynamic_cast<TaskLineDecor*>(widget);
if (parent != nullptr) {
restore = new TaskRestoreLines(partFeat, parent);
restoreBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-linedecor"),
tr("Restore Invisible Lines"), true, 0);
restoreBox->groupLayout()->addWidget(restore);
Content.push_back(restoreBox);
}
}
TaskDlgLineDecor::~TaskDlgLineDecor()

View File

@@ -54,6 +54,8 @@ public:
public:
virtual bool accept();
virtual bool reject();
bool apply(void) { return m_apply; }
void apply(bool b) { m_apply = b; }
protected Q_SLOTS:
void onStyleChanged(void);
@@ -75,6 +77,7 @@ private:
App::Color m_color;
double m_weight;
bool m_visible;
bool m_apply;
};
class TaskRestoreLines : public QWidget
@@ -82,7 +85,8 @@ class TaskRestoreLines : public QWidget
Q_OBJECT
public:
TaskRestoreLines(TechDraw::DrawViewPart* partFeat);
TaskRestoreLines(TechDraw::DrawViewPart* partFeat,
TechDrawGui::TaskLineDecor* parent);
~TaskRestoreLines();
public:
@@ -110,6 +114,7 @@ protected:
private:
Ui_TaskRestoreLines* ui;
TechDraw::DrawViewPart* m_partFeat;
TaskLineDecor* m_parent;
};

View File

@@ -188,13 +188,8 @@
<item row="0" column="2">
<widget class="QComboBox" name="cb_Style">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<item>
<property name="text">
<string>NoLine</string>
</property>
</item>
<item>
<property name="text">
<string>Solid</string>