FreeCAD

Форк
0
/
TaskWeldingSymbol.cpp 
656 строк · 22.6 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2019 WandererFan <wandererfan@gmail.com>                *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
# include <cmath>
26
# include <QPushButton>
27
#endif // #ifndef _PreComp_
28

29
#include <App/Document.h>
30
#include <Base/Console.h>
31
#include <Base/Tools.h>
32
#include <Gui/BitmapFactory.h>
33
#include <Gui/Command.h>
34
#include <Gui/Document.h>
35

36
#include <Mod/TechDraw/App/DrawPage.h>
37
#include <Mod/TechDraw/App/DrawLeaderLine.h>
38
#include <Mod/TechDraw/App/DrawTileWeld.h>
39
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
40

41
#include "TaskWeldingSymbol.h"
42
#include "ui_TaskWeldingSymbol.h"
43
#include "PreferencesGui.h"
44
#include "SymbolChooser.h"
45

46

47
using namespace Gui;
48
using namespace TechDraw;
49
using namespace TechDrawGui;
50

51
//ctor for creation
52
TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawLeaderLine* leadFeat) :
53
    ui(new Ui_TaskWeldingSymbol),
54
    m_leadFeat(leadFeat),
55
    m_weldFeat(nullptr),
56
    m_arrowFeat(nullptr),
57
    m_otherFeat(nullptr),
58
    m_btnOK(nullptr),
59
    m_btnCancel(nullptr),
60
    m_createMode(true),
61
    m_otherDirty(false)
62
{
63

64
    //existence of leader is guaranteed by CmdTechDrawWeldSymbol (CommandAnnotate.cpp)
65
    ui->setupUi(this);
66

67
    setUiPrimary();
68

69
    connect(ui->pbArrowSymbol, &QPushButton::clicked,
70
            this, &TaskWeldingSymbol::onArrowSymbolCreateClicked);
71
    connect(ui->pbOtherSymbol, &QPushButton::clicked,
72
            this, &TaskWeldingSymbol::onOtherSymbolCreateClicked);
73
    connect(ui->pbOtherErase, &QPushButton::clicked,
74
            this, &TaskWeldingSymbol::onOtherEraseCreateClicked);
75
    connect(ui->pbFlipSides, &QPushButton::clicked,
76
            this, &TaskWeldingSymbol::onFlipSidesCreateClicked);
77
    connect(ui->fcSymbolDir, &FileChooser::fileNameSelected,
78
            this, &TaskWeldingSymbol::onDirectorySelected);
79
}
80

81
//ctor for edit
82
TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawWeldSymbol* weld) :
83
    ui(new Ui_TaskWeldingSymbol),
84
    m_leadFeat(nullptr),
85
    m_weldFeat(weld),
86
    m_arrowFeat(nullptr),
87
    m_otherFeat(nullptr),
88
    m_btnOK(nullptr),
89
    m_btnCancel(nullptr),
90
    m_createMode(false),
91
    m_otherDirty(false)
92
{
93
    //existence of weld is guaranteed by CmdTechDrawWeldSymbol (CommandAnnotate.cpp)
94
    //                                or ViewProviderWeld.setEdit
95

96
    App::DocumentObject* obj = m_weldFeat->Leader.getValue();
97
    if (!obj ||
98
        !obj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId()) )  {
99
        Base::Console().Error("TaskWeldingSymbol - no leader for welding symbol.  Can not proceed.\n");
100
        return;
101
    }
102

103
    m_leadFeat = static_cast<TechDraw::DrawLeaderLine*>(obj);
104

105
    ui->setupUi(this);
106

107
    setUiEdit();
108

109
    connect(ui->pbArrowSymbol, &QPushButton::clicked,
110
        this, &TaskWeldingSymbol::onArrowSymbolClicked);
111
    connect(ui->pbOtherSymbol, &QPushButton::clicked,
112
        this, &TaskWeldingSymbol::onOtherSymbolClicked);
113
    connect(ui->pbOtherErase, &QPushButton::clicked,
114
        this, &TaskWeldingSymbol::onOtherEraseClicked);
115
    connect(ui->pbFlipSides, &QPushButton::clicked,
116
        this, &TaskWeldingSymbol::onFlipSidesClicked);
117

118
    connect(ui->fcSymbolDir, &FileChooser::fileNameSelected,
119
        this, &TaskWeldingSymbol::onDirectorySelected);
120

121
    connect(ui->leArrowTextL, &QLineEdit::textEdited,
122
        this, &TaskWeldingSymbol::onArrowTextChanged);
123
    connect(ui->leArrowTextR, &QLineEdit::textEdited,
124
        this, &TaskWeldingSymbol::onArrowTextChanged);
125
    connect(ui->leArrowTextC, &QLineEdit::textEdited,
126
        this, &TaskWeldingSymbol::onArrowTextChanged);
127

128
    connect(ui->leOtherTextL, &QLineEdit::textEdited,
129
        this, &TaskWeldingSymbol::onOtherTextChanged);
130
    connect(ui->leOtherTextR, &QLineEdit::textEdited,
131
        this, &TaskWeldingSymbol::onOtherTextChanged);
132
    connect(ui->leOtherTextC, &QLineEdit::textEdited,
133
        this, &TaskWeldingSymbol::onOtherTextChanged);
134

135
    connect(ui->leTailText, &QLineEdit::textEdited,
136
        this, &TaskWeldingSymbol::onWeldingChanged);
137
    connect(ui->cbFieldWeld, &QCheckBox::toggled,
138
        this, &TaskWeldingSymbol::onWeldingChanged);
139
    connect(ui->cbAllAround, &QCheckBox::toggled,
140
        this, &TaskWeldingSymbol::onWeldingChanged);
141
    connect(ui->cbAltWeld, &QCheckBox::toggled,
142
        this, &TaskWeldingSymbol::onWeldingChanged);
143
}
144

145
TaskWeldingSymbol::~TaskWeldingSymbol()
146
{
147
}
148

149
void TaskWeldingSymbol::updateTask()
150
{
151
//    blockUpdate = true;
152

153
//    blockUpdate = false;
154
}
155

156
void TaskWeldingSymbol::changeEvent(QEvent *event)
157
{
158
    if (event->type() == QEvent::LanguageChange) {
159
        ui->retranslateUi(this);
160
    }
161
}
162

163
void TaskWeldingSymbol::setUiPrimary()
164
{
165
//    Base::Console().Message("TWS::setUiPrimary()\n");
166
    setWindowTitle(QObject::tr("Create Welding Symbol"));
167
    m_currDir = PreferencesGui::weldingDirectory();
168
    ui->fcSymbolDir->setFileName(m_currDir);
169

170
    ui->pbArrowSymbol->setFocus();
171
    m_arrowOut.init();
172
    m_arrowPath = QString();
173
    m_arrowSymbol = QString();
174
    m_otherOut.init();
175
    m_otherPath = QString();
176
    m_otherSymbol = QString();
177

178
    // we must mark the other side dirty to assure it gets created
179
    m_otherDirty = true;
180
}
181

182
void TaskWeldingSymbol::setUiEdit()
183
{
184
//    Base::Console().Message("TWS::setUiEdit()\n");
185
    setWindowTitle(QObject::tr("Edit Welding Symbol"));
186

187
    m_currDir = PreferencesGui::weldingDirectory();
188
    ui->fcSymbolDir->setFileName(m_currDir);
189

190
    ui->cbAllAround->setChecked(m_weldFeat->AllAround.getValue());
191
    ui->cbFieldWeld->setChecked(m_weldFeat->FieldWeld.getValue());
192
    ui->cbAltWeld->setChecked(m_weldFeat->AlternatingWeld.getValue());
193
    ui->leTailText->setText(QString::fromUtf8(m_weldFeat->TailText.getValue()));
194

195
    getTileFeats();
196
    if (m_arrowFeat) {
197
        QString qTemp = QString::fromUtf8(m_arrowFeat->LeftText.getValue());
198
        ui->leArrowTextL->setText(qTemp);
199
        qTemp = QString::fromUtf8(m_arrowFeat->RightText.getValue());
200
        ui->leArrowTextR->setText(qTemp);
201
        qTemp = QString::fromUtf8(m_arrowFeat->CenterText.getValue());
202
        ui->leArrowTextC->setText(qTemp);
203

204
        std::string inFile = m_arrowFeat->SymbolFile.getValue();
205
        auto fi = Base::FileInfo(inFile);
206
        if (fi.isReadable()) {
207
            qTemp = QString::fromUtf8(m_arrowFeat->SymbolFile.getValue());
208
            QIcon targetIcon(qTemp);
209
            QSize iconSize(32, 32);
210
            ui->pbArrowSymbol->setIcon(targetIcon);
211
            ui->pbArrowSymbol->setIconSize(iconSize);
212
            ui->pbArrowSymbol->setText(QString());
213
        } else {
214
            ui->pbArrowSymbol->setText(tr("Symbol"));
215
        }
216
    }
217

218
    if (m_otherFeat) {
219
        QString qTemp = QString::fromUtf8(m_otherFeat->LeftText.getValue());
220
        ui->leOtherTextL->setText(qTemp);
221
        qTemp = QString::fromUtf8(m_otherFeat->RightText.getValue());
222
        ui->leOtherTextR->setText(qTemp);
223
        qTemp = QString::fromUtf8(m_otherFeat->CenterText.getValue());
224
        ui->leOtherTextC->setText(qTemp);
225

226
        std::string inFile = m_otherFeat->SymbolFile.getValue();
227
        auto fi = Base::FileInfo(inFile);
228
        if (fi.isReadable()) {
229
            qTemp = QString::fromUtf8(m_otherFeat->SymbolFile.getValue());
230
            QIcon targetIcon(qTemp);
231
            QSize iconSize(32, 32);
232
            ui->pbOtherSymbol->setIcon(targetIcon);
233
            ui->pbOtherSymbol->setIconSize(iconSize);
234
            ui->pbOtherSymbol->setText(QString());
235
        } else {
236
            ui->pbOtherSymbol->setText(tr("Symbol"));
237
        }
238
    }
239

240
    ui->pbArrowSymbol->setFocus();
241
}
242

243
void TaskWeldingSymbol::symbolDialog(const char* source)
244
{
245
    QString _source = tr(source);
246
    SymbolChooser* dlg = new SymbolChooser(this, m_currDir, _source);
247
    connect(dlg, &SymbolChooser::symbolSelected,
248
            this, &TaskWeldingSymbol::onSymbolSelected);
249
    dlg->setAttribute(Qt::WA_DeleteOnClose);
250
    dlg->exec();
251
}
252

253
void TaskWeldingSymbol::onArrowSymbolCreateClicked()
254
{
255
    symbolDialog("arrow");
256
}
257

258
void TaskWeldingSymbol::onArrowSymbolClicked()
259
{
260
    symbolDialog("arrow");
261
    updateTiles();
262
    m_weldFeat->requestPaint();
263
}
264

265
void TaskWeldingSymbol::onOtherSymbolCreateClicked()
266
{
267
    symbolDialog("other");
268
}
269

270
void TaskWeldingSymbol::onOtherSymbolClicked()
271
{
272
    symbolDialog("other");
273
    updateTiles();
274
    m_weldFeat->requestPaint();
275
}
276

277
void TaskWeldingSymbol::onOtherEraseCreateClicked()
278
{
279
    ui->leOtherTextL->setText(QString());
280
    ui->leOtherTextC->setText(QString());
281
    ui->leOtherTextR->setText(QString());
282
    ui->pbOtherSymbol->setIcon(QIcon());
283
    ui->pbOtherSymbol->setText(tr("Symbol"));
284
    m_otherOut.init();
285
    m_otherPath = QString();
286
}
287

288
void TaskWeldingSymbol::onOtherEraseClicked()
289
{
290
    m_otherDirty = true;
291
    ui->leOtherTextL->setText(QString());
292
    ui->leOtherTextC->setText(QString());
293
    ui->leOtherTextR->setText(QString());
294
    ui->pbOtherSymbol->setIcon(QIcon());
295
    ui->pbOtherSymbol->setText(tr("Symbol"));
296
    m_otherOut.init();
297
    m_otherPath = QString();
298
    updateTiles();
299
    m_weldFeat->requestPaint();
300
}
301

302
void TaskWeldingSymbol::onFlipSidesCreateClicked()
303
{
304
    QString tempText = ui->leOtherTextL->text();
305
    ui->leOtherTextL->setText(ui->leArrowTextL->text());
306
    ui->leArrowTextL->setText(tempText);
307
    tempText = ui->leOtherTextC->text();
308
    ui->leOtherTextC->setText(ui->leArrowTextC->text());
309
    ui->leArrowTextC->setText(tempText);
310
    tempText = ui->leOtherTextR->text();
311
    ui->leOtherTextR->setText(ui->leArrowTextR->text());
312
    ui->leArrowTextR->setText(tempText);
313

314
    QString tempPathArrow = m_otherPath;
315
    m_otherPath = m_arrowPath;
316
    m_arrowPath = tempPathArrow;
317
    tempText = ui->pbOtherSymbol->text();
318
    ui->pbOtherSymbol->setText(ui->pbArrowSymbol->text());
319
    ui->pbArrowSymbol->setText(tempText);
320
    QIcon tempIcon = ui->pbOtherSymbol->icon();
321
    ui->pbOtherSymbol->setIcon(ui->pbArrowSymbol->icon());
322
    ui->pbArrowSymbol->setIcon(tempIcon);
323
}
324

325
void TaskWeldingSymbol::onFlipSidesClicked()
326
{
327
    QString tempText = ui->leOtherTextL->text();
328
    ui->leOtherTextL->setText(ui->leArrowTextL->text());
329
    ui->leArrowTextL->setText(tempText);
330
    tempText = ui->leOtherTextC->text();
331
    ui->leOtherTextC->setText(ui->leArrowTextC->text());
332
    ui->leArrowTextC->setText(tempText);
333
    tempText = ui->leOtherTextR->text();
334
    ui->leOtherTextR->setText(ui->leArrowTextR->text());
335
    ui->leArrowTextR->setText(tempText);
336

337
    // one cannot get the path from the icon therefore read out
338
    // the path property
339
    auto tempPathArrow = m_arrowFeat->SymbolFile.getValue();
340
    auto tempPathOther = m_otherFeat->SymbolFile.getValue();
341
    m_otherPath = QString::fromLatin1(tempPathArrow);
342
    m_arrowPath = QString::fromLatin1(tempPathOther);
343
    QIcon tempIcon = ui->pbOtherSymbol->icon();
344
    ui->pbOtherSymbol->setIcon(ui->pbArrowSymbol->icon());
345
    ui->pbArrowSymbol->setIcon(tempIcon);
346

347
    m_otherDirty = true;
348
    updateTiles();
349
    m_weldFeat->requestPaint();
350
}
351

352
void TaskWeldingSymbol::onArrowTextChanged()
353
{
354
    updateTiles();
355
    m_weldFeat->requestPaint();
356
}
357

358
void TaskWeldingSymbol::onOtherTextChanged()
359
{
360
    m_otherDirty = true;
361
    updateTiles();
362
    m_weldFeat->requestPaint();
363
}
364

365
void TaskWeldingSymbol::onWeldingChanged()
366
{
367
    updateWeldingSymbol();
368
    m_weldFeat->requestPaint();
369
}
370

371
void TaskWeldingSymbol::onDirectorySelected(const QString& newDir)
372
{
373
//    Base::Console().Message("TWS::onDirectorySelected(%s)\n", qPrintable(newDir));
374
    m_currDir = newDir + QString::fromUtf8("/");
375
}
376

377
void TaskWeldingSymbol::onSymbolSelected(QString symbolPath,
378
                                         QString source)
379
{
380
//    Base::Console().Message("TWS::onSymbolSelected(%s) - source: %s\n",
381
//                            qPrintable(symbolPath), qPrintable(source));
382
    QIcon targetIcon(symbolPath);
383
    QSize iconSize(32, 32);
384
    QString arrow = tr("arrow");
385
    QString other = tr("other");
386
    if (source == arrow) {
387
        ui->pbArrowSymbol->setIcon(targetIcon);
388
        ui->pbArrowSymbol->setIconSize(iconSize);
389
        ui->pbArrowSymbol->setText(QString());
390
        m_arrowPath = symbolPath;
391
    } else if (source == other) {
392
        m_otherDirty = true;
393
        ui->pbOtherSymbol->setIcon(targetIcon);
394
        ui->pbOtherSymbol->setIconSize(iconSize);
395
        ui->pbOtherSymbol->setText(QString());
396
        m_otherPath = symbolPath;
397
    }
398
}
399

400
void TaskWeldingSymbol::collectArrowData()
401
{
402
//    Base::Console().Message("TWS::collectArrowData()\n");
403
    m_arrowOut.toBeSaved = true;
404
    m_arrowOut.arrowSide = false;
405
    m_arrowOut.row = 0;
406
    m_arrowOut.col = 0;
407
    m_arrowOut.leftText = ui->leArrowTextL->text().toStdString();
408
    m_arrowOut.centerText = ui->leArrowTextC->text().toStdString();
409
    m_arrowOut.rightText = ui->leArrowTextR->text().toStdString();
410
    m_arrowOut.symbolPath= m_arrowPath.toStdString();
411
    m_arrowOut.tileName = "";
412
}
413

414
void TaskWeldingSymbol::collectOtherData()
415
{
416
//    Base::Console().Message("TWS::collectOtherData()\n");
417
    m_otherOut.toBeSaved = true;
418
    m_otherOut.arrowSide = false;
419
    m_otherOut.row = -1;
420
    m_otherOut.col = 0;
421
    m_otherOut.leftText = ui->leOtherTextL->text().toStdString();
422
    m_otherOut.centerText = ui->leOtherTextC->text().toStdString();
423
    m_otherOut.rightText = ui->leOtherTextR->text().toStdString();
424
    m_otherOut.symbolPath = m_otherPath.toStdString();
425
    m_otherOut.tileName = "";
426
}
427

428
void TaskWeldingSymbol::getTileFeats()
429
{
430
//    Base::Console().Message("TWS::getTileFeats()\n");
431
    std::vector<TechDraw::DrawTileWeld*> tiles = m_weldFeat->getTiles();
432
    m_arrowFeat = nullptr;
433
    m_otherFeat = nullptr;
434

435
    if (tiles.empty()) {
436
        return;
437
    }
438

439
    TechDraw::DrawTileWeld* tempTile = tiles.at(0);
440
    if (tempTile->TileRow.getValue() == 0) {
441
        m_arrowFeat = tempTile;
442
    } else {
443
        m_otherFeat = tempTile;
444
    }
445
    if (tiles.size() > 1) {
446
        TechDraw::DrawTileWeld* tempTile = tiles.at(1);
447
        if (tempTile->TileRow.getValue() == 0) {
448
            m_arrowFeat = tempTile;
449
        } else {
450
            m_otherFeat = tempTile;
451
        }
452
    }
453
}
454

455
//******************************************************************************
456
TechDraw::DrawWeldSymbol* TaskWeldingSymbol::createWeldingSymbol()
457
{
458
//    Base::Console().Message("TWS::createWeldingSymbol()\n");
459
    App::Document *doc = Application::Instance->activeDocument()->getDocument();
460
    auto weldSymbol = dynamic_cast<TechDraw::DrawWeldSymbol*>(doc->addObject("TechDraw::DrawWeldSymbol", "WeldSymbol"));
461
    if (!weldSymbol) {
462
        throw Base::RuntimeError("TaskWeldingSymbol - new symbol object not found");
463
    }
464

465
    weldSymbol->AllAround.setValue(ui->cbAllAround->isChecked());
466
    weldSymbol->FieldWeld.setValue(ui->cbFieldWeld->isChecked());
467
    weldSymbol->AlternatingWeld.setValue(ui->cbAltWeld->isChecked());
468
    weldSymbol->TailText.setValue(ui->leTailText->text().toStdString());
469
    weldSymbol->Leader.setValue(m_leadFeat);
470

471
    TechDraw::DrawPage *page = m_leadFeat->findParentPage();
472
    if (page) {
473
        page->addView(weldSymbol);
474
    }
475

476
    return weldSymbol;
477
}
478

479
void TaskWeldingSymbol::updateWeldingSymbol()
480
{
481
    m_weldFeat->AllAround.setValue(ui->cbAllAround->isChecked());
482
    m_weldFeat->FieldWeld.setValue(ui->cbFieldWeld->isChecked());
483
    m_weldFeat->AlternatingWeld.setValue(ui->cbAltWeld->isChecked());
484
    m_weldFeat->TailText.setValue(ui->leTailText->text().toStdString());
485
}
486

487
void TaskWeldingSymbol::updateTiles()
488
{
489
//    Base::Console().Message("TWS::updateTiles()\n");
490
    getTileFeats();
491

492
    if (!m_arrowFeat) {
493
        Base::Console().Message("TWS::updateTiles - no arrow tile!\n");
494
    } else {
495
        collectArrowData();
496
        if (m_arrowOut.toBeSaved) {
497
            std::string tileName = m_arrowFeat->getNameInDocument();
498
            std::string leftText = Base::Tools::escapeEncodeString(m_arrowOut.leftText);
499
            std::string rightText = Base::Tools::escapeEncodeString(m_arrowOut.rightText);
500
            std::string centerText = Base::Tools::escapeEncodeString(m_arrowOut.centerText);
501
            Command::doCommand(Command::Doc, "App.activeDocument().%s.TileColumn = %d",
502
                           tileName.c_str(), m_arrowOut.col);
503
            Command::doCommand(Command::Doc, "App.activeDocument().%s.LeftText = '%s'",
504
                           tileName.c_str(), leftText.c_str());
505
            Command::doCommand(Command::Doc, "App.activeDocument().%s.RightText = '%s'",
506
                           tileName.c_str(), rightText.c_str());
507
            Command::doCommand(Command::Doc, "App.activeDocument().%s.CenterText = '%s'",
508
                           tileName.c_str(), centerText.c_str());
509
            if (!m_arrowOut.symbolPath.empty()) {
510
//                m_arrowFeat->replaceSymbol(m_arrowOut.symbolPath);
511
                m_arrowFeat->SymbolFile.setValue(m_arrowOut.symbolPath);
512
            }
513
        }
514
    }
515

516
    if (!m_otherFeat) {
517
//        Base::Console().Message("TWS::updateTiles - no other tile!\n");
518
    } else {
519
        if (m_otherDirty) {
520
            collectOtherData();
521
            if (m_otherOut.toBeSaved) {
522
                std::string tileName = m_otherFeat->getNameInDocument();
523
                std::string leftText = Base::Tools::escapeEncodeString(m_otherOut.leftText);
524
                std::string rightText = Base::Tools::escapeEncodeString(m_otherOut.rightText);
525
                std::string centerText = Base::Tools::escapeEncodeString(m_otherOut.centerText);
526
                Command::doCommand(Command::Doc, "App.activeDocument().%s.TileColumn = %d",
527
                               tileName.c_str(), m_otherOut.col);
528
                Command::doCommand(Command::Doc, "App.activeDocument().%s.LeftText = '%s'",
529
                               tileName.c_str(), leftText.c_str());
530
                Command::doCommand(Command::Doc, "App.activeDocument().%s.RightText = '%s'",
531
                               tileName.c_str(), rightText.c_str());
532
                Command::doCommand(Command::Doc, "App.activeDocument().%s.CenterText = '%s'",
533
                               tileName.c_str(), centerText.c_str());
534
//                m_otherFeat->replaceSymbol(m_otherOut.symbolPath);
535
                m_otherFeat->SymbolFile.setValue(m_otherOut.symbolPath);
536
            }
537
        }
538
    }
539
    return;
540
}
541

542
void TaskWeldingSymbol::saveButtons(QPushButton* btnOK,
543
                             QPushButton* btnCancel)
544
{
545
    m_btnOK = btnOK;
546
    m_btnCancel = btnCancel;
547
}
548

549
void TaskWeldingSymbol::enableTaskButtons(bool enable)
550
{
551
    m_btnOK->setEnabled(enable);
552
    m_btnCancel->setEnabled(enable);
553
}
554

555
//******************************************************************************
556

557
bool TaskWeldingSymbol::accept()
558
{
559
//    Base::Console().Message("TWS::accept()\n");
560
    if (m_createMode) {
561
        Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create WeldSymbol"));
562
        m_weldFeat = createWeldingSymbol();
563
        updateTiles();
564
        Gui::Command::updateActive();
565
        Gui::Command::commitCommand();
566
        m_weldFeat->recomputeFeature();
567
    //    m_weldFeat->requestPaint();    //not a dv!
568
    } else {
569
        Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit WeldSymbol"));
570
        try {
571
            updateWeldingSymbol();
572
            updateTiles();
573
        }
574
        catch (...) {
575
            Base::Console().Error("TWS::accept - failed to update symbol\n");
576
        }
577

578
        Gui::Command::updateActive();
579
        Gui::Command::commitCommand();
580
        m_weldFeat->recomputeFeature();
581
    //    m_weldFeat->requestPaint();    //not a dv!
582
    }
583
    Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
584

585
    return true;
586
}
587

588
bool TaskWeldingSymbol::reject()
589
{
590
//    Base::Console().Message("TWS::reject()\n");
591
      //nothing to remove.
592

593
    Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()");
594
    Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
595

596
    return false;
597
}
598
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
599
TaskDlgWeldingSymbol::TaskDlgWeldingSymbol(TechDraw::DrawLeaderLine* leader)
600
    : TaskDialog()
601
{
602
    widget  = new TaskWeldingSymbol(leader);
603
    taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_WeldSymbol"),
604
                                             widget->windowTitle(), true, nullptr);
605
    taskbox->groupLayout()->addWidget(widget);
606
    Content.push_back(taskbox);
607
}
608

609
TaskDlgWeldingSymbol::TaskDlgWeldingSymbol(TechDraw::DrawWeldSymbol* weld)
610
    : TaskDialog()
611
{
612
    widget  = new TaskWeldingSymbol(weld);
613
    taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_WeldSymbol"),
614
                                             widget->windowTitle(), true, nullptr);
615
    taskbox->groupLayout()->addWidget(widget);
616
    Content.push_back(taskbox);
617
}
618

619
TaskDlgWeldingSymbol::~TaskDlgWeldingSymbol()
620
{
621
}
622

623
void TaskDlgWeldingSymbol::update()
624
{
625
//    widget->updateTask();
626
}
627

628
void TaskDlgWeldingSymbol::modifyStandardButtons(QDialogButtonBox* box)
629
{
630
    QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
631
    QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
632
    widget->saveButtons(btnOK, btnCancel);
633
}
634

635
//==== calls from the TaskView ===============================================================
636
void TaskDlgWeldingSymbol::open()
637
{
638
}
639

640
void TaskDlgWeldingSymbol::clicked(int)
641
{
642
}
643

644
bool TaskDlgWeldingSymbol::accept()
645
{
646
    widget->accept();
647
    return true;
648
}
649

650
bool TaskDlgWeldingSymbol::reject()
651
{
652
    widget->reject();
653
    return true;
654
}
655

656
#include <Mod/TechDraw/Gui/moc_TaskWeldingSymbol.cpp>
657

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.