FreeCAD

Форк
0
/
DlgDisplayPropertiesImp.cpp 
646 строк · 25.5 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de>              *
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 <algorithm>
26
# include <boost_signals2.hpp>
27
# include <QDockWidget>
28
# include <QSignalBlocker>
29
#endif
30

31
#include <Base/Console.h>
32

33
#include "DlgDisplayPropertiesImp.h"
34
#include "ui_DlgDisplayProperties.h"
35
#include "Application.h"
36
#include "Document.h"
37
#include "DlgMaterialPropertiesImp.h"
38
#include "DockWindowManager.h"
39
#include "Selection.h"
40
#include "ViewProvider.h"
41
#include "WaitCursor.h"
42

43

44
using namespace Gui::Dialog;
45
using namespace std;
46
namespace sp = std::placeholders;
47

48

49
/* TRANSLATOR Gui::Dialog::DlgDisplayPropertiesImp */
50

51
#if 0 // needed for Qt's lupdate utility
52
    qApp->translate("QDockWidget", "Display properties");
53
#endif
54

55
class DlgDisplayPropertiesImp::Private
56
{
57
    using DlgDisplayPropertiesImp_Connection = boost::signals2::connection;
58
public:
59
    Ui::DlgDisplayProperties ui;
60
    bool floating;
61
    DlgDisplayPropertiesImp_Connection connectChangedObject;
62

63
    static void setElementColor(const std::vector<Gui::ViewProvider*>& views, const char* property, Gui::ColorButton* buttonColor)
64
    {
65
        bool hasElementColor = false;
66
        for (const auto & view : views) {
67
            if (auto* prop = dynamic_cast<App::PropertyColor*>(view->getPropertyByName(property))) {
68
                App::Color color = prop->getValue();
69
                QSignalBlocker block(buttonColor);
70
                buttonColor->setColor(color.asValue<QColor>());
71
                hasElementColor = true;
72
                break;
73
            }
74
        }
75

76
        buttonColor->setEnabled(hasElementColor);
77
    }
78

79
    static void setDrawStyle(const std::vector<Gui::ViewProvider*>& views, const char* property, QSpinBox* spinbox)
80
    {
81
        bool hasDrawStyle = false;
82
        for (const auto & view : views) {
83
            if (auto* prop = dynamic_cast<App::PropertyFloat*>(view->getPropertyByName(property))) {
84
                QSignalBlocker block(spinbox);
85
                spinbox->setValue(int(prop->getValue()));
86
                hasDrawStyle = true;
87
                break;
88
            }
89
        }
90

91
        spinbox->setEnabled(hasDrawStyle);
92
    }
93

94
    static void setTransparency(const std::vector<Gui::ViewProvider*>& views, const char* property, QSpinBox* spinbox, QSlider* slider)
95
    {
96
        bool hasTransparency = false;
97
        for (const auto & view : views) {
98
            if (auto* prop = dynamic_cast<App::PropertyInteger*>(view->getPropertyByName(property))) {
99
                QSignalBlocker blockSpinBox(spinbox);
100
                spinbox->setValue(prop->getValue());
101

102
                QSignalBlocker blockSlider(slider);
103
                slider->setValue(prop->getValue());
104
                hasTransparency = true;
105
                break;
106
            }
107
        }
108

109
        spinbox->setEnabled(hasTransparency);
110
        slider->setEnabled(hasTransparency);
111
    }
112
};
113

114
/**
115
 *  Constructs a DlgDisplayPropertiesImp which is a child of 'parent', with the
116
 *  name 'name' and widget flags set to 'f'
117
 *
118
 *  The dialog will by default be modeless, unless you set 'modal' to
119
 *  true to construct a modal dialog.
120
 */
121
DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent, Qt::WindowFlags fl)
122
  : QDialog( parent, fl )
123
  , d(new Private)
124
{
125
    d->ui.setupUi(this);
126
    setupConnections();
127

128
    d->ui.textLabel1_3->hide();
129
    d->ui.changePlot->hide();
130
    d->ui.buttonLineColor->setModal(false);
131
    d->ui.buttonPointColor->setModal(false);
132
    d->ui.buttonColor->setModal(false);
133
    d->floating = floating;
134

135
    std::vector<Gui::ViewProvider*> views = getSelection();
136
    setDisplayModes(views);
137
    fillupMaterials();
138
    setMaterial(views);
139
    setColorPlot(views);
140
    setShapeColor(views);
141
    setLineColor(views);
142
    setPointColor(views);
143
    setPointSize(views);
144
    setLineWidth(views);
145
    setTransparency(views);
146
    setLineTransparency(views);
147

148
    // embed this dialog into a dockable widget container
149
    if (floating) {
150
        Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
151
        QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
152
        dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
153
        dw->setFloating(true);
154
        dw->show();
155
    }
156

157
    Gui::Selection().Attach(this);
158

159
    //NOLINTBEGIN
160
    d->connectChangedObject =
161
    Gui::Application::Instance->signalChangedObject.connect(std::bind
162
        (&DlgDisplayPropertiesImp::slotChangedObject, this, sp::_1, sp::_2));
163
    //NOLINTEND
164
}
165

166
/**
167
 *  Destroys the object and frees any allocated resources
168
 */
169
DlgDisplayPropertiesImp::~DlgDisplayPropertiesImp()
170
{
171
    // no need to delete child widgets, Qt does it all for us
172
    d->connectChangedObject.disconnect();
173
    Gui::Selection().Detach(this);
174
}
175

176
void DlgDisplayPropertiesImp::setupConnections()
177
{
178
#if QT_VERSION < QT_VERSION_CHECK(5,14,0)
179
    connect(d->ui.changeMode, qOverload<const QString&>(&QComboBox::activated), this, &DlgDisplayPropertiesImp::onChangeModeActivated);
180
    connect(d->ui.changePlot, qOverload<const QString&>(&QComboBox::activated), this, &DlgDisplayPropertiesImp::onChangePlotActivated);
181
#else
182
    connect(d->ui.changeMode, &QComboBox::textActivated, this, &DlgDisplayPropertiesImp::onChangeModeActivated);
183
    connect(d->ui.changePlot, &QComboBox::textActivated, this, &DlgDisplayPropertiesImp::onChangePlotActivated);
184
#endif
185
    connect(d->ui.changeMaterial, qOverload<int>(&QComboBox::activated), this, &DlgDisplayPropertiesImp::onChangeMaterialActivated);
186
    connect(d->ui.buttonColor, &ColorButton::changed, this, &DlgDisplayPropertiesImp::onButtonColorChanged);
187
    connect(d->ui.spinTransparency, qOverload<int>(&QSpinBox::valueChanged), this, &DlgDisplayPropertiesImp::onSpinTransparencyValueChanged);
188
    connect(d->ui.spinPointSize, qOverload<int>(&QSpinBox::valueChanged), this, &DlgDisplayPropertiesImp::onSpinPointSizeValueChanged);
189
    connect(d->ui.buttonLineColor, &ColorButton::changed, this, &DlgDisplayPropertiesImp::onButtonLineColorChanged);
190
    connect(d->ui.buttonPointColor, &ColorButton::changed, this, &DlgDisplayPropertiesImp::onButtonPointColorChanged);
191
    connect(d->ui.spinLineWidth, qOverload<int>(&QSpinBox::valueChanged), this, &DlgDisplayPropertiesImp::onSpinLineWidthValueChanged);
192
    connect(d->ui.spinLineTransparency, qOverload<int>(&QSpinBox::valueChanged), this, &DlgDisplayPropertiesImp::onSpinLineTransparencyValueChanged);
193
    connect(d->ui.buttonUserDefinedMaterial, &ColorButton::clicked, this, &DlgDisplayPropertiesImp::onButtonUserDefinedMaterialClicked);
194
    connect(d->ui.buttonColorPlot, &ColorButton::clicked, this, &DlgDisplayPropertiesImp::onButtonColorPlotClicked);
195
}
196

197
void DlgDisplayPropertiesImp::changeEvent(QEvent *e)
198
{
199
    if (e->type() == QEvent::LanguageChange) {
200
        d->ui.retranslateUi(this);
201
    }
202
    QDialog::changeEvent(e);
203
}
204

205
/// @cond DOXERR
206
void DlgDisplayPropertiesImp::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
207
                                       Gui::SelectionSingleton::MessageType Reason)
208
{
209
    Q_UNUSED(rCaller);
210
    if (Reason.Type == SelectionChanges::AddSelection ||
211
        Reason.Type == SelectionChanges::RmvSelection ||
212
        Reason.Type == SelectionChanges::SetSelection ||
213
        Reason.Type == SelectionChanges::ClrSelection) {
214
        std::vector<Gui::ViewProvider*> views = getSelection();
215
        setDisplayModes(views);
216
        setMaterial(views);
217
        setColorPlot(views);
218
        setShapeColor(views);
219
        setLineColor(views);
220
        setPointColor(views);
221
        setPointSize(views);
222
        setLineWidth(views);
223
        setTransparency(views);
224
        setLineTransparency(views);
225
    }
226
}
227
/// @endcond
228

229
void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
230
                                                const App::Property& prop)
231
{
232
    // This method gets called if a property of any view provider is changed.
233
    // We pick out all the properties for which we need to update this dialog.
234
    std::vector<Gui::ViewProvider*> Provider = getSelection();
235
    auto vp = std::find_if(Provider.begin(),
236
                           Provider.end(),
237
                           [&obj](Gui::ViewProvider* v) { return v == &obj; });
238

239
    if (vp != Provider.end()) {
240
        const char* name = obj.getPropertyName(&prop);
241
        // this is not a property of the view provider but of the document object
242
        if (!name)
243
            return;
244
        std::string prop_name = name;
245
        if (prop.is<App::PropertyColor>()) {
246
            App::Color value = static_cast<const App::PropertyColor&>(prop).getValue();
247
            if (prop_name == "ShapeColor") {
248
                bool blocked = d->ui.buttonColor->blockSignals(true);
249
                d->ui.buttonColor->setColor(QColor((int)(255.0f * value.r),
250
                                                   (int)(255.0f * value.g),
251
                                                   (int)(255.0f * value.b)));
252
                d->ui.buttonColor->blockSignals(blocked);
253
            }
254
            else if (prop_name == "LineColor") {
255
                bool blocked = d->ui.buttonLineColor->blockSignals(true);
256
                d->ui.buttonLineColor->setColor(QColor((int)(255.0f * value.r),
257
                                                       (int)(255.0f * value.g),
258
                                                       (int)(255.0f * value.b)));
259
                d->ui.buttonLineColor->blockSignals(blocked);
260
            }
261
            else if (prop_name == "PointColor") {
262
                bool blocked = d->ui.buttonPointColor->blockSignals(true);
263
                d->ui.buttonPointColor->setColor(QColor((int)(255.0f * value.r),
264
                                                       (int)(255.0f * value.g),
265
                                                       (int)(255.0f * value.b)));
266
                d->ui.buttonPointColor->blockSignals(blocked);
267
            }
268
        }
269
        else if (prop.isDerivedFrom<App::PropertyInteger>()) {
270
            long value = static_cast<const App::PropertyInteger&>(prop).getValue();
271
            if (prop_name == "Transparency") {
272
                bool blocked = d->ui.spinTransparency->blockSignals(true);
273
                d->ui.spinTransparency->setValue(value);
274
                d->ui.spinTransparency->blockSignals(blocked);
275
                blocked = d->ui.horizontalSlider->blockSignals(true);
276
                d->ui.horizontalSlider->setValue(value);
277
                d->ui.horizontalSlider->blockSignals(blocked);
278
            }
279
            else if (prop_name == "LineTransparency") {
280
                bool blocked = d->ui.spinLineTransparency->blockSignals(true);
281
                d->ui.spinLineTransparency->setValue(value);
282
                d->ui.spinLineTransparency->blockSignals(blocked);
283
                blocked = d->ui.sliderLineTransparency->blockSignals(true);
284
                d->ui.sliderLineTransparency->setValue(value);
285
                d->ui.sliderLineTransparency->blockSignals(blocked);
286
            }
287
        }
288
        else if (prop.isDerivedFrom<App::PropertyFloat>()) {
289
            double value = static_cast<const App::PropertyFloat&>(prop).getValue();
290
            if (prop_name == "PointSize") {
291
                bool blocked = d->ui.spinPointSize->blockSignals(true);
292
                d->ui.spinPointSize->setValue((int)value);
293
                d->ui.spinPointSize->blockSignals(blocked);
294
            }
295
            else if (prop_name == "LineWidth") {
296
                bool blocked = d->ui.spinLineWidth->blockSignals(true);
297
                d->ui.spinLineWidth->setValue((int)value);
298
                d->ui.spinLineWidth->blockSignals(blocked);
299
            }
300
        }
301
    }
302
}
303

304
/**
305
 * Destroys the dock window this object is embedded into without destroying itself.
306
 */
307
void DlgDisplayPropertiesImp::reject()
308
{
309
    if (d->floating) {
310
        // closes the dock window
311
        Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
312
        pDockMgr->removeDockWindow(this);
313
    }
314
    QDialog::reject();
315
}
316

317
/**
318
 * Opens a dialog that allows to modify the 'ShapeMaterial' property of all selected view providers.
319
 */
320
void DlgDisplayPropertiesImp::onButtonUserDefinedMaterialClicked()
321
{
322
    std::vector<Gui::ViewProvider*> Provider = getSelection();
323
    DlgMaterialPropertiesImp dlg("ShapeMaterial", this);
324
    dlg.setViewProviders(Provider);
325
    dlg.exec();
326

327
    d->ui.buttonColor->setColor(dlg.diffuseColor());
328
}
329

330
/**
331
 * Opens a dialog that allows to modify the 'ShapeMaterial' property of all selected view providers.
332
 */
333
void DlgDisplayPropertiesImp::onButtonColorPlotClicked()
334
{
335
    std::vector<Gui::ViewProvider*> Provider = getSelection();
336
    static QPointer<DlgMaterialPropertiesImp> dlg = nullptr;
337
    if (!dlg)
338
        dlg = new DlgMaterialPropertiesImp("TextureMaterial", this);
339
    dlg->setModal(false);
340
    dlg->setAttribute(Qt::WA_DeleteOnClose);
341
    dlg->setViewProviders(Provider);
342
    dlg->show();
343
}
344

345
/**
346
 * Sets the 'ShapeMaterial' property of all selected view providers.
347
 */
348
void DlgDisplayPropertiesImp::onChangeMaterialActivated(int index)
349
{
350
    std::vector<Gui::ViewProvider*> Provider = getSelection();
351
    App::Material::MaterialType matType = static_cast<App::Material::MaterialType>(d->ui.changeMaterial->itemData(index).toInt());
352
    App::Material mat(matType);
353
    App::Color diffuseColor = mat.diffuseColor;
354
    d->ui.buttonColor->setColor(QColor((int)(diffuseColor.r*255.0f),
355
                                       (int)(diffuseColor.g*255.0f),
356
                                       (int)(diffuseColor.b*255.0f)));
357

358
    for (auto it : Provider) {
359
        if (auto* prop = dynamic_cast<App::PropertyMaterial*>(it->getPropertyByName("ShapeMaterial"))) {
360
            prop->setValue(mat);
361
        }
362
    }
363
}
364

365
/**
366
 * Sets the 'Display' property of all selected view providers.
367
 */
368
void DlgDisplayPropertiesImp::onChangeModeActivated(const QString& s)
369
{
370
    Gui::WaitCursor wc;
371
    std::vector<Gui::ViewProvider*> Provider = getSelection();
372
    for (auto it : Provider) {
373
        if (auto* prop = dynamic_cast<App::PropertyEnumeration*>(it->getPropertyByName("DisplayMode"))) {
374
            prop->setValue(static_cast<const char*>(s.toLatin1()));
375
        }
376
    }
377
}
378

379
void DlgDisplayPropertiesImp::onChangePlotActivated(const QString&s)
380
{
381
    Base::Console().Log("Plot = %s\n",(const char*)s.toLatin1());
382
}
383

384
/**
385
 * Sets the 'ShapeColor' property of all selected view providers.
386
 */
387
void DlgDisplayPropertiesImp::onButtonColorChanged()
388
{
389
    std::vector<Gui::ViewProvider*> Provider = getSelection();
390
    QColor s = d->ui.buttonColor->color();
391
    App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0);
392
    for (auto it : Provider) {
393
        if (auto* prop = dynamic_cast<App::PropertyColor*>(it->getPropertyByName("ShapeColor"))) {
394
            prop->setValue(c);
395
        }
396
    }
397
}
398

399
/**
400
 * Sets the 'Transparency' property of all selected view providers.
401
 */
402
void DlgDisplayPropertiesImp::onSpinTransparencyValueChanged(int transparency)
403
{
404
    std::vector<Gui::ViewProvider*> Provider = getSelection();
405
    for (auto it : Provider) {
406
        if (auto* prop = dynamic_cast<App::PropertyInteger*>(it->getPropertyByName("Transparency"))) {
407
            prop->setValue(transparency);
408
        }
409
    }
410
}
411

412
/**
413
 * Sets the 'PointSize' property of all selected view providers.
414
 */
415
void DlgDisplayPropertiesImp::onSpinPointSizeValueChanged(int pointsize)
416
{
417
    std::vector<Gui::ViewProvider*> Provider = getSelection();
418
    for (auto it : Provider) {
419
        if (auto* prop = dynamic_cast<App::PropertyFloat*>(it->getPropertyByName("PointSize"))) {
420
            prop->setValue(static_cast<double>(pointsize));
421
        }
422
    }
423
}
424

425
/**
426
 * Sets the 'LineWidth' property of all selected view providers.
427
 */
428
void DlgDisplayPropertiesImp::onSpinLineWidthValueChanged(int linewidth)
429
{
430
    std::vector<Gui::ViewProvider*> Provider = getSelection();
431
    for (auto it : Provider) {
432
        if (auto* prop = dynamic_cast<App::PropertyFloat*>(it->getPropertyByName("LineWidth"))) {
433
            prop->setValue(static_cast<double>(linewidth));
434
        }
435
    }
436
}
437

438
void DlgDisplayPropertiesImp::onButtonLineColorChanged()
439
{
440
    std::vector<Gui::ViewProvider*> Provider = getSelection();
441
    QColor s = d->ui.buttonLineColor->color();
442
    App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0);
443
    for (auto it : Provider) {
444
        if (auto* prop = dynamic_cast<App::PropertyColor*>(it->getPropertyByName("LineColor"))) {
445
            prop->setValue(c);
446
        }
447
    }
448
}
449

450
void DlgDisplayPropertiesImp::onButtonPointColorChanged()
451
{
452
    std::vector<Gui::ViewProvider*> Provider = getSelection();
453
    QColor s = d->ui.buttonPointColor->color();
454
    App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0);
455
    for (auto it : Provider) {
456
        if (auto* prop = dynamic_cast<App::PropertyColor*>(it->getPropertyByName("PointColor"))) {
457
            prop->setValue(c);
458
        }
459
    }
460
}
461

462
void DlgDisplayPropertiesImp::onSpinLineTransparencyValueChanged(int transparency)
463
{
464
    std::vector<Gui::ViewProvider*> Provider = getSelection();
465
    for (auto it : Provider) {
466
        if (auto* prop = dynamic_cast<App::PropertyInteger*>(it->getPropertyByName("LineTransparency"))) {
467
            prop->setValue(transparency);
468
        }
469
    }
470
}
471

472
void DlgDisplayPropertiesImp::setDisplayModes(const std::vector<Gui::ViewProvider*>& views)
473
{
474
    QStringList commonModes, modes;
475
    for (auto it = views.begin(); it != views.end(); ++it) {
476
        if (auto* prop = dynamic_cast<App::PropertyEnumeration*>((*it)->getPropertyByName("DisplayMode"))) {
477
            if (!prop->hasEnums())
478
                return;
479
            std::vector<std::string> value = prop->getEnumVector();
480
            if (it == views.begin()) {
481
                for (const auto & jt : value)
482
                    commonModes << QLatin1String(jt.c_str());
483
            }
484
            else {
485
                for (const auto & jt : value) {
486
                    if (commonModes.contains(QLatin1String(jt.c_str())))
487
                        modes << QLatin1String(jt.c_str());
488
                }
489

490
                commonModes = modes;
491
                modes.clear();
492
            }
493
        }
494
    }
495

496
    d->ui.changeMode->clear();
497
    d->ui.changeMode->addItems(commonModes);
498
    d->ui.changeMode->setDisabled(commonModes.isEmpty());
499

500
    // find the display mode to activate
501
    for (const auto & view : views) {
502
        if (auto* prop = dynamic_cast<App::PropertyEnumeration*>(view->getPropertyByName("DisplayMode"))) {
503
            QString activeMode = QString::fromLatin1(prop->getValueAsString());
504
            int index = d->ui.changeMode->findText(activeMode);
505
            if (index != -1) {
506
                d->ui.changeMode->setCurrentIndex(index);
507
                break;
508
            }
509
        }
510
    }
511
}
512

513
void DlgDisplayPropertiesImp::setMaterial(const std::vector<Gui::ViewProvider*>& views)
514
{
515
    bool material = false;
516
    App::Material::MaterialType matType = App::Material::DEFAULT;
517
    for (auto view : views) {
518
        if (auto* prop = dynamic_cast<App::PropertyMaterial*>(view->getPropertyByName("ShapeMaterial"))) {
519
            material = true;
520
            matType = prop->getValue().getType();
521
            break;
522
        }
523
    }
524

525
    int index = d->ui.changeMaterial->findData(matType);
526
    if (index >= 0) {
527
        d->ui.changeMaterial->setCurrentIndex(index);
528
    }
529
    d->ui.changeMaterial->setEnabled(material);
530
    d->ui.buttonUserDefinedMaterial->setEnabled(material);
531
}
532

533
void DlgDisplayPropertiesImp::setColorPlot(const std::vector<Gui::ViewProvider*>& views)
534
{
535
    bool material = false;
536
    for (auto view : views) {
537
        auto* prop = dynamic_cast<App::PropertyMaterial*>(view->getPropertyByName("TextureMaterial"));
538
        if (prop) {
539
            material = true;
540
            break;
541
        }
542
    }
543

544
    d->ui.buttonColorPlot->setEnabled(material);
545
}
546

547
void DlgDisplayPropertiesImp::fillupMaterials()
548
{
549
    d->ui.changeMaterial->addItem(tr("Default"), App::Material::DEFAULT);
550
    d->ui.changeMaterial->addItem(tr("Aluminium"), App::Material::ALUMINIUM);
551
    d->ui.changeMaterial->addItem(tr("Brass"), App::Material::BRASS);
552
    d->ui.changeMaterial->addItem(tr("Bronze"), App::Material::BRONZE);
553
    d->ui.changeMaterial->addItem(tr("Copper"), App::Material::COPPER);
554
    d->ui.changeMaterial->addItem(tr("Chrome"), App::Material::CHROME);
555
    d->ui.changeMaterial->addItem(tr("Emerald"), App::Material::EMERALD);
556
    d->ui.changeMaterial->addItem(tr("Gold"), App::Material::GOLD);
557
    d->ui.changeMaterial->addItem(tr("Jade"), App::Material::JADE);
558
    d->ui.changeMaterial->addItem(tr("Metalized"), App::Material::METALIZED);
559
    d->ui.changeMaterial->addItem(tr("Neon GNC"), App::Material::NEON_GNC);
560
    d->ui.changeMaterial->addItem(tr("Neon PHC"), App::Material::NEON_PHC);
561
    d->ui.changeMaterial->addItem(tr("Obsidian"), App::Material::OBSIDIAN);
562
    d->ui.changeMaterial->addItem(tr("Pewter"), App::Material::PEWTER);
563
    d->ui.changeMaterial->addItem(tr("Plaster"), App::Material::PLASTER);
564
    d->ui.changeMaterial->addItem(tr("Plastic"), App::Material::PLASTIC);
565
    d->ui.changeMaterial->addItem(tr("Ruby"), App::Material::RUBY);
566
    d->ui.changeMaterial->addItem(tr("Satin"), App::Material::SATIN);
567
    d->ui.changeMaterial->addItem(tr("Shiny plastic"), App::Material::SHINY_PLASTIC);
568
    d->ui.changeMaterial->addItem(tr("Silver"), App::Material::SILVER);
569
    d->ui.changeMaterial->addItem(tr("Steel"), App::Material::STEEL);
570
    d->ui.changeMaterial->addItem(tr("Stone"), App::Material::STONE);
571
}
572

573
void DlgDisplayPropertiesImp::setShapeColor(const std::vector<Gui::ViewProvider*>& views)
574
{
575
    Private::setElementColor(views, "ShapeColor", d->ui.buttonColor);
576
}
577

578
void DlgDisplayPropertiesImp::setLineColor(const std::vector<Gui::ViewProvider*>& views)
579
{
580
    Private::setElementColor(views, "LineColor", d->ui.buttonLineColor);
581
}
582

583
void DlgDisplayPropertiesImp::setPointColor(const std::vector<Gui::ViewProvider*>& views)
584
{
585
    Private::setElementColor(views, "PointColor", d->ui.buttonPointColor);
586
}
587

588
void DlgDisplayPropertiesImp::setPointSize(const std::vector<Gui::ViewProvider*>& views)
589
{
590
    Private::setDrawStyle(views, "PointSize", d->ui.spinPointSize);
591
}
592

593
void DlgDisplayPropertiesImp::setLineWidth(const std::vector<Gui::ViewProvider*>& views)
594
{
595
    Private::setDrawStyle(views, "LineWidth", d->ui.spinLineWidth);
596
}
597

598
void DlgDisplayPropertiesImp::setTransparency(const std::vector<Gui::ViewProvider*>& views)
599
{
600
    Private::setTransparency(views, "Transparency", d->ui.spinTransparency, d->ui.horizontalSlider);
601
}
602

603
void DlgDisplayPropertiesImp::setLineTransparency(const std::vector<Gui::ViewProvider*>& views)
604
{
605
    Private::setTransparency(views, "LineTransparency", d->ui.spinLineTransparency, d->ui.sliderLineTransparency);
606
}
607

608
std::vector<Gui::ViewProvider*> DlgDisplayPropertiesImp::getSelection() const
609
{
610
    std::vector<Gui::ViewProvider*> views;
611

612
    // get the complete selection
613
    std::vector<SelectionSingleton::SelObj> sel = Selection().getCompleteSelection();
614
    for (const auto & it : sel) {
615
        Gui::ViewProvider* view = Application::Instance->getDocument(it.pDoc)->getViewProvider(it.pObject);
616
        views.push_back(view);
617
    }
618

619
    return views;
620
}
621

622
// ----------------------------------------------------------------------------
623

624
/* TRANSLATOR Gui::Dialog::TaskDisplayProperties */
625

626
TaskDisplayProperties::TaskDisplayProperties()
627
{
628
    this->setButtonPosition(TaskDisplayProperties::North);
629
    widget = new DlgDisplayPropertiesImp(false);
630
    addTaskBox(widget);
631
}
632

633
TaskDisplayProperties::~TaskDisplayProperties() = default;
634

635
QDialogButtonBox::StandardButtons TaskDisplayProperties::getStandardButtons() const
636
{
637
    return QDialogButtonBox::Close;
638
}
639

640
bool TaskDisplayProperties::reject()
641
{
642
    widget->reject();
643
    return (widget->result() == QDialog::Rejected);
644
}
645

646
#include "moc_DlgDisplayPropertiesImp.cpp"
647

648

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

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

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

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