diff --git a/src/Mod/TechDraw/App/DrawGeomHatch.cpp b/src/Mod/TechDraw/App/DrawGeomHatch.cpp index a08ea73845..fd3ed9a20e 100644 --- a/src/Mod/TechDraw/App/DrawGeomHatch.cpp +++ b/src/Mod/TechDraw/App/DrawGeomHatch.cpp @@ -126,8 +126,13 @@ void DrawGeomHatch::onChanged(const App::Property* prop) (doc != nullptr) ) { if (!FilePattern.isEmpty()) { replacePatIncluded(FilePattern.getValue()); + DrawGeomHatch::execute(); //remake the line sets } } + if ((prop == &NamePattern) && + (doc != nullptr)) { + DrawGeomHatch::execute(); //remake the line sets + } } else { if ((prop == &FilePattern) || //make sure right pattern gets loaded at start up (prop == &NamePattern)) { @@ -144,7 +149,8 @@ short DrawGeomHatch::mustExecute() const if (!isRestoring()) { result = (Source.isTouched() || FilePattern.isTouched() || - NamePattern.isTouched() ); + NamePattern.isTouched() || + ScalePattern.isTouched()); } if (result) { @@ -171,18 +177,13 @@ void DrawGeomHatch::makeLineSets(void) // Base::Console().Message("DGH::makeLineSets()\n"); if ((!PatIncluded.isEmpty()) && (!NamePattern.isEmpty())) { - if ((m_saveFile != PatIncluded.getValue()) || - (m_saveName != NamePattern.getValue())) { - m_saveFile = PatIncluded.getValue(); - m_saveName = NamePattern.getValue(); - std::vector specs = getDecodedSpecsFromFile(); - m_lineSets.clear(); - for (auto& hl: specs) { - //hl.dump("hl from file"); - LineSet ls; - ls.setPATLineSpec(hl); - m_lineSets.push_back(ls); - } + std::vector specs = getDecodedSpecsFromFile(); + m_lineSets.clear(); + for (auto& hl: specs) { + //hl.dump("hl from file"); + LineSet ls; + ls.setPATLineSpec(hl); + m_lineSets.push_back(ls); } } } diff --git a/src/Mod/TechDraw/App/HatchLine.cpp b/src/Mod/TechDraw/App/HatchLine.cpp index acd03cf833..00b3ed5681 100644 --- a/src/Mod/TechDraw/App/HatchLine.cpp +++ b/src/Mod/TechDraw/App/HatchLine.cpp @@ -317,7 +317,8 @@ std::vector PATLineSpec::getSpecsForPattern(std::string& parmFile, if (status) { lineSpecs = loadPatternDef(inFile); } else { - Base::Console().Message( "Could not find pattern: %s\n",parmName.c_str() ); + //this message can come up when changing PAT file or pattern name + Base::Console().Log( "Could not find pattern: %s\n",parmName.c_str() ); return result; } @@ -331,6 +332,7 @@ std::vector PATLineSpec::getSpecsForPattern(std::string& parmFile, bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName) { +// Base::Console().Message("HL::findPatternStart() - parmName: %s\n", parmName.c_str()); bool result = false; while ( inFile.good() ){ std::string line; diff --git a/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp b/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp index 1f38fa7d4d..53c63c2961 100644 --- a/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp +++ b/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp @@ -97,32 +97,6 @@ void TaskGeomHatch::initUi() connect(ui->ccColor, SIGNAL(changed()), this, SLOT(onColorChanged())); } -//move values from screen to DocObjs -void TaskGeomHatch::updateValues() -{ - m_file = (ui->fcFile->fileName()).toUtf8().constData(); - m_hatch->FilePattern.setValue(m_file); - QString cText = ui->cbName->currentText(); - m_name = cText.toUtf8().constData(); - m_hatch->NamePattern.setValue(m_name); - m_scale = ui->sbScale->value().getValue(); - m_hatch->ScalePattern.setValue(m_scale); - m_color.setValue(ui->ccColor->color()); - m_Vp->ColorPattern.setValue(m_color); - m_weight = ui->sbWeight->value().getValue(); - m_Vp->WeightPattern.setValue(m_weight); -} - -QStringList TaskGeomHatch::listToQ(std::vector in) -{ - QStringList result; - for (auto& s: in) { - QString qs = QString::fromUtf8(s.data(), s.size()); - result.append(qs); - } - return result; -} - void TaskGeomHatch::onFileChanged(void) { m_file = ui->fcFile->fileName().toUtf8().constData(); @@ -130,16 +104,9 @@ void TaskGeomHatch::onFileChanged(void) QStringList qsNames = listToQ(names); ui->cbName->clear(); ui->cbName->addItems(qsNames); -} - -bool TaskGeomHatch::accept() -{ - updateValues(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); - m_source->touch(); - m_source->getDocument()->recompute(); //TODO: this is only here to get graphics to update. - // sb "redraw graphics" since m_source geom has not changed. - return true; + m_hatch->FilePattern.setValue(m_file); + onNameChanged(); //pattern name from old file is not + //necessarily present in new file! } void TaskGeomHatch::onNameChanged() @@ -147,27 +114,39 @@ void TaskGeomHatch::onNameChanged() QString cText = ui->cbName->currentText(); m_name = cText.toUtf8().constData(); m_hatch->NamePattern.setValue(m_name); - m_source->getDocument()->recompute(); } void TaskGeomHatch::onScaleChanged() { + m_scale = ui->sbScale->value().getValue(); m_hatch->ScalePattern.setValue(ui->sbScale->value().getValue()); - m_source->getDocument()->recompute(); + TechDraw::DrawView* dv = static_cast(m_source); + dv->requestPaint(); } void TaskGeomHatch::onLineWeightChanged() { + m_weight =ui->sbWeight->value().getValue(); m_Vp->WeightPattern.setValue(ui->sbWeight->value().getValue()); - m_source->getDocument()->recompute(); + TechDraw::DrawView* dv = static_cast(m_source); + dv->requestPaint(); } void TaskGeomHatch::onColorChanged() { - App::Color ac; - ac.setValue(ui->ccColor->color()); - m_Vp->ColorPattern.setValue(ac); - m_source->getDocument()->recompute(); + m_color.setValue(ui->ccColor->color()); + m_Vp->ColorPattern.setValue(m_color); +} + +bool TaskGeomHatch::accept() +{ +// Base::Console().Message("TGH::accept()\n"); + updateValues(); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + m_hatch->recomputeFeature(); //create the hatch lines + TechDraw::DrawView* dv = static_cast(m_source); + dv->requestPaint(); + return true; } bool TaskGeomHatch::reject() @@ -202,7 +181,33 @@ void TaskGeomHatch::getParameters() m_origColor = m_Vp->ColorPattern.getValue(); m_origWeight = m_Vp->WeightPattern.getValue(); } - +} + +//move values from screen to DocObjs +void TaskGeomHatch::updateValues() +{ +// Base::Console().Message("TGH::updateValues()\n"); + m_file = (ui->fcFile->fileName()).toUtf8().constData(); + m_hatch->FilePattern.setValue(m_file); + QString cText = ui->cbName->currentText(); + m_name = cText.toUtf8().constData(); + m_hatch->NamePattern.setValue(m_name); + m_scale = ui->sbScale->value().getValue(); + m_hatch->ScalePattern.setValue(m_scale); + m_color.setValue(ui->ccColor->color()); + m_Vp->ColorPattern.setValue(m_color); + m_weight = ui->sbWeight->value().getValue(); + m_Vp->WeightPattern.setValue(m_weight); +} + +QStringList TaskGeomHatch::listToQ(std::vector in) +{ + QStringList result; + for (auto& s: in) { + QString qs = QString::fromUtf8(s.data(), s.size()); + result.append(qs); + } + return result; } void TaskGeomHatch::changeEvent(QEvent *e)