FreeCAD

Форк
0
/
SelectionView.cpp 
703 строки · 25.3 Кб
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 <QCheckBox>
26
#include <QLabel>
27
#include <QLineEdit>
28
#include <QListWidget>
29
#include <QListWidgetItem>
30
#include <QMenu>
31
#include <QTextStream>
32
#include <QToolButton>
33
#include <QVBoxLayout>
34
#endif
35

36
#include <App/ComplexGeoData.h>
37
#include <App/Document.h>
38
#include <App/GeoFeature.h>
39

40
#include "SelectionView.h"
41
#include "Application.h"
42
#include "BitmapFactory.h"
43
#include "Command.h"
44
#include "Document.h"
45

46

47
FC_LOG_LEVEL_INIT("Selection", true, true, true)
48

49
using namespace Gui;
50
using namespace Gui::DockWnd;
51

52

53
/* TRANSLATOR Gui::DockWnd::SelectionView */
54

55
SelectionView::SelectionView(Gui::Document* pcDocument, QWidget* parent)
56
    : DockWindow(pcDocument, parent)
57
    , SelectionObserver(true, ResolveMode::NoResolve)
58
    , x(0.0f)
59
    , y(0.0f)
60
    , z(0.0f)
61
    , openedAutomatically(false)
62
{
63
    setWindowTitle(tr("Selection View"));
64

65
    QVBoxLayout* vLayout = new QVBoxLayout(this);
66
    vLayout->setSpacing(0);
67
    vLayout->setContentsMargins(0, 0, 0, 0);
68

69
    QLineEdit* searchBox = new QLineEdit(this);
70
    searchBox->setPlaceholderText(tr("Search"));
71
    searchBox->setToolTip(tr("Searches object labels"));
72
    QHBoxLayout* hLayout = new QHBoxLayout();
73
    hLayout->setSpacing(2);
74
    QToolButton* clearButton = new QToolButton(this);
75
    clearButton->setFixedSize(18, 21);
76
    clearButton->setCursor(Qt::ArrowCursor);
77
    clearButton->setStyleSheet(QString::fromUtf8("QToolButton {margin-bottom:1px}"));
78
    clearButton->setIcon(BitmapFactory().pixmap(":/icons/edit-cleartext.svg"));
79
    clearButton->setToolTip(tr("Clears the search field"));
80
    clearButton->setAutoRaise(true);
81
    countLabel = new QLabel(this);
82
    countLabel->setText(QString::fromUtf8("0"));
83
    countLabel->setToolTip(tr("The number of selected items"));
84
    hLayout->addWidget(searchBox);
85
    hLayout->addWidget(clearButton, 0, Qt::AlignRight);
86
    hLayout->addWidget(countLabel, 0, Qt::AlignRight);
87
    vLayout->addLayout(hLayout);
88

89
    selectionView = new QListWidget(this);
90
    selectionView->setContextMenuPolicy(Qt::CustomContextMenu);
91
    vLayout->addWidget(selectionView);
92

93
    enablePickList = new QCheckBox(this);
94
    enablePickList->setText(tr("Picked object list"));
95
    vLayout->addWidget(enablePickList);
96
    pickList = new QListWidget(this);
97
    pickList->setVisible(false);
98
    vLayout->addWidget(pickList);
99

100
    selectionView->setMouseTracking(true);  // needed for itemEntered() to work
101
    pickList->setMouseTracking(true);
102

103
    resize(200, 200);
104

105
    // clang-format off
106
    connect(clearButton, &QToolButton::clicked, searchBox, &QLineEdit::clear);
107
    connect(searchBox, &QLineEdit::textChanged, this, &SelectionView::search);
108
    connect(searchBox, &QLineEdit::editingFinished, this, &SelectionView::validateSearch);
109
    connect(selectionView, &QListWidget::itemDoubleClicked, this, &SelectionView::toggleSelect);
110
    connect(selectionView, &QListWidget::itemEntered, this, &SelectionView::preselect);
111
    connect(pickList, &QListWidget::itemDoubleClicked, this, &SelectionView::toggleSelect);
112
    connect(pickList, &QListWidget::itemEntered, this, &SelectionView::preselect);
113
    connect(selectionView, &QListWidget::customContextMenuRequested, this, &SelectionView::onItemContextMenu);
114
    connect(enablePickList, &QCheckBox::stateChanged, this, &SelectionView::onEnablePickList);
115
    // clang-format on
116
}
117

118
SelectionView::~SelectionView() = default;
119

120
void SelectionView::leaveEvent(QEvent*)
121
{
122
    Selection().rmvPreselect();
123
}
124

125
/// @cond DOXERR
126
void SelectionView::onSelectionChanged(const SelectionChanges& Reason)
127
{
128
    ParameterGrp::handle hGrp = App::GetApplication()
129
                                    .GetUserParameter()
130
                                    .GetGroup("BaseApp")
131
                                    ->GetGroup("Preferences")
132
                                    ->GetGroup("Selection");
133
    bool autoShow = hGrp->GetBool("AutoShowSelectionView", false);
134
    hGrp->SetBool("AutoShowSelectionView",
135
                  autoShow);  // Remove this line once the preferences window item is implemented
136

137
    if (autoShow) {
138
        if (!parentWidget()->isVisible() && Selection().hasSelection()) {
139
            parentWidget()->show();
140
            openedAutomatically = true;
141
        }
142
        else if (openedAutomatically && !Selection().hasSelection()) {
143
            parentWidget()->hide();
144
            openedAutomatically = false;
145
        }
146
    }
147

148
    QString selObject;
149
    QTextStream str(&selObject);
150

151
    auto getSelectionName = [](QTextStream& str,
152
                               const char* docName,
153
                               const char* objName,
154
                               const char* subName,
155
                               App::DocumentObject* obj) {
156
        str << docName;
157
        str << "#";
158
        str << objName;
159
        if (subName != 0 && subName[0] != 0) {
160
            str << ".";
161
            /* Original code doesn't take account of histories in subelement names and displays
162
             * them inadvertently.  Let's not do that.
163
            str << subName;
164
            */
165
            /* Remove the history from the displayed subelement name */
166
            App::ElementNamePair elementName;
167
            App::GeoFeature::resolveElement(obj, subName, elementName);
168
            str << elementName.oldName.c_str();  // Use the shortened element name not the full one.
169
            /* Mark it visually if there was a history as a "tell" for if a given selection has TNP
170
             * fixes in it. */
171
            if (elementName.newName.size() > 0) {
172
                str << " []";
173
            }
174
            auto subObj = obj->getSubObject(subName);
175
            if (subObj) {
176
                obj = subObj;
177
            }
178
        }
179
        str << " (";
180
        str << QString::fromUtf8(obj->Label.getValue());
181
        str << ")";
182
    };
183

184
    if (Reason.Type == SelectionChanges::AddSelection) {
185
        // save as user data
186
        QStringList list;
187
        list << QString::fromLatin1(Reason.pDocName);
188
        list << QString::fromLatin1(Reason.pObjectName);
189
        App::Document* doc = App::GetApplication().getDocument(Reason.pDocName);
190
        App::DocumentObject* obj = doc->getObject(Reason.pObjectName);
191
        getSelectionName(str, Reason.pDocName, Reason.pObjectName, Reason.pSubName, obj);
192

193
        // insert the selection as item
194
        QListWidgetItem* item = new QListWidgetItem(selObject, selectionView);
195
        item->setData(Qt::UserRole, list);
196
    }
197
    else if (Reason.Type == SelectionChanges::ClrSelection) {
198
        if (!Reason.pDocName[0]) {
199
            // remove all items
200
            selectionView->clear();
201
        }
202
        else {
203
            // build name
204
            str << Reason.pDocName;
205
            str << "#";
206
            // remove all items
207
            const auto items = selectionView->findItems(selObject, Qt::MatchStartsWith);
208
            for (auto item : items) {
209
                delete item;
210
            }
211
        }
212
    }
213
    else if (Reason.Type == SelectionChanges::RmvSelection) {
214
        App::Document* doc = App::GetApplication().getDocument(Reason.pDocName);
215
        App::DocumentObject* obj = doc->getObject(Reason.pObjectName);
216
        getSelectionName(str, Reason.pDocName, Reason.pObjectName, Reason.pSubName, obj);
217
        // remove all items
218
        QList<QListWidgetItem*> l = selectionView->findItems(selObject, Qt::MatchStartsWith);
219
        if (l.size() == 1) {
220
            delete l[0];
221
        }
222
    }
223
    else if (Reason.Type == SelectionChanges::SetSelection) {
224
        // remove all items
225
        selectionView->clear();
226
        std::vector<SelectionSingleton::SelObj> objs =
227
            Gui::Selection().getSelection(Reason.pDocName, ResolveMode::NoResolve);
228
        for (const auto& it : objs) {
229
            // save as user data
230
            QStringList list;
231
            list << QString::fromLatin1(it.DocName);
232
            list << QString::fromLatin1(it.FeatName);
233

234
            App::Document* doc = App::GetApplication().getDocument(it.DocName);
235
            App::DocumentObject* obj = doc->getObject(it.FeatName);
236
            getSelectionName(str, it.DocName, it.FeatName, it.SubName, obj);
237
            QListWidgetItem* item = new QListWidgetItem(selObject, selectionView);
238
            item->setData(Qt::UserRole, list);
239
            selObject.clear();
240
        }
241
    }
242
    else if (Reason.Type == SelectionChanges::PickedListChanged) {
243
        bool picking = Selection().needPickedList();
244
        enablePickList->setChecked(picking);
245
        pickList->setVisible(picking);
246
        pickList->clear();
247
        if (picking) {
248
            const auto& sels = Selection().getPickedList(Reason.pDocName);
249
            for (const auto& sel : sels) {
250
                App::Document* doc = App::GetApplication().getDocument(sel.DocName);
251
                if (!doc) {
252
                    continue;
253
                }
254
                App::DocumentObject* obj = doc->getObject(sel.FeatName);
255
                if (!obj) {
256
                    continue;
257
                }
258

259
                QString selObject;
260
                QTextStream str(&selObject);
261
                getSelectionName(str, sel.DocName, sel.FeatName, sel.SubName, obj);
262

263
                this->x = sel.x;
264
                this->y = sel.y;
265
                this->z = sel.z;
266

267
                new QListWidgetItem(selObject, pickList);
268
            }
269
        }
270
    }
271

272
    countLabel->setText(QString::number(selectionView->count()));
273
}
274

275
void SelectionView::search(const QString& text)
276
{
277
    if (!text.isEmpty()) {
278
        searchList.clear();
279
        App::Document* doc = App::GetApplication().getActiveDocument();
280
        std::vector<App::DocumentObject*> objects;
281
        if (doc) {
282
            objects = doc->getObjects();
283
            selectionView->clear();
284
            for (auto it : objects) {
285
                QString label = QString::fromUtf8(it->Label.getValue());
286
                if (label.contains(text, Qt::CaseInsensitive)) {
287
                    searchList.push_back(it);
288
                    // save as user data
289
                    QString selObject;
290
                    QTextStream str(&selObject);
291
                    QStringList list;
292
                    list << QString::fromLatin1(doc->getName());
293
                    list << QString::fromLatin1(it->getNameInDocument());
294
                    // build name
295
                    str << QString::fromUtf8(doc->Label.getValue());
296
                    str << "#";
297
                    str << it->getNameInDocument();
298
                    str << " (";
299
                    str << label;
300
                    str << ")";
301
                    QListWidgetItem* item = new QListWidgetItem(selObject, selectionView);
302
                    item->setData(Qt::UserRole, list);
303
                }
304
            }
305
            countLabel->setText(QString::number(selectionView->count()));
306
        }
307
    }
308
}
309

310
void SelectionView::validateSearch()
311
{
312
    if (!searchList.empty()) {
313
        App::Document* doc = App::GetApplication().getActiveDocument();
314
        if (doc) {
315
            Gui::Selection().clearSelection();
316
            for (auto it : searchList) {
317
                Gui::Selection().addSelection(doc->getName(), it->getNameInDocument(), nullptr);
318
            }
319
        }
320
    }
321
}
322

323
void SelectionView::select(QListWidgetItem* item)
324
{
325
    if (!item) {
326
        item = selectionView->currentItem();
327
    }
328
    if (!item) {
329
        return;
330
    }
331
    QStringList elements = item->data(Qt::UserRole).toStringList();
332
    if (elements.size() < 2) {
333
        return;
334
    }
335

336
    try {
337
        // Gui::Selection().clearSelection();
338
        Gui::Command::runCommand(Gui::Command::Gui, "Gui.Selection.clearSelection()");
339
        // Gui::Selection().addSelection(elements[0].toLatin1(),elements[1].toLatin1(),0);
340
        QString cmd = QString::fromLatin1(
341
                          R"(Gui.Selection.addSelection(App.getDocument("%1").getObject("%2")))")
342
                          .arg(elements[0], elements[1]);
343
        Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
344
    }
345
    catch (Base::Exception& e) {
346
        e.ReportException();
347
    }
348
}
349

350
void SelectionView::deselect()
351
{
352
    QListWidgetItem* item = selectionView->currentItem();
353
    if (!item) {
354
        return;
355
    }
356
    QStringList elements = item->data(Qt::UserRole).toStringList();
357
    if (elements.size() < 2) {
358
        return;
359
    }
360

361
    // Gui::Selection().rmvSelection(elements[0].toLatin1(),elements[1].toLatin1(),0);
362
    QString cmd = QString::fromLatin1(
363
                      R"(Gui.Selection.removeSelection(App.getDocument("%1").getObject("%2")))")
364
                      .arg(elements[0], elements[1]);
365
    try {
366
        Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
367
    }
368
    catch (Base::Exception& e) {
369
        e.ReportException();
370
    }
371
}
372

373
void SelectionView::toggleSelect(QListWidgetItem* item)
374
{
375
    if (!item) {
376
        return;
377
    }
378
    std::string name = item->text().toLatin1().constData();
379
    char* docname = &name.at(0);
380
    char* objname = std::strchr(docname, '#');
381
    if (!objname) {
382
        return;
383
    }
384
    *objname++ = 0;
385
    char* subname = std::strchr(objname, '.');
386
    if (subname) {
387
        *subname++ = 0;
388
        char* end = std::strchr(subname, ' ');
389
        if (end) {
390
            *end = 0;
391
        }
392
    }
393
    else {
394
        char* end = std::strchr(objname, ' ');
395
        if (end) {
396
            *end = 0;
397
        }
398
    }
399
    QString cmd;
400
    if (Gui::Selection().isSelected(docname, objname, subname)) {
401
        cmd = QString::fromLatin1("Gui.Selection.removeSelection("
402
                                  "App.getDocument('%1').getObject('%2'),'%3')")
403
                  .arg(QString::fromLatin1(docname),
404
                       QString::fromLatin1(objname),
405
                       QString::fromLatin1(subname));
406
    }
407
    else {
408
        cmd = QString::fromLatin1("Gui.Selection.addSelection("
409
                                  "App.getDocument('%1').getObject('%2'),'%3',%4,%5,%6)")
410
                  .arg(QString::fromLatin1(docname),
411
                       QString::fromLatin1(objname),
412
                       QString::fromLatin1(subname))
413
                  .arg(x)
414
                  .arg(y)
415
                  .arg(z);
416
    }
417
    try {
418
        Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
419
    }
420
    catch (Base::Exception& e) {
421
        e.ReportException();
422
    }
423
}
424

425
void SelectionView::preselect(QListWidgetItem* item)
426
{
427
    if (!item) {
428
        return;
429
    }
430
    std::string name = item->text().toLatin1().constData();
431
    char* docname = &name.at(0);
432
    char* objname = std::strchr(docname, '#');
433
    if (!objname) {
434
        return;
435
    }
436
    *objname++ = 0;
437
    char* subname = std::strchr(objname, '.');
438
    if (subname) {
439
        *subname++ = 0;
440
        char* end = std::strchr(subname, ' ');
441
        if (end) {
442
            *end = 0;
443
        }
444
    }
445
    else {
446
        char* end = std::strchr(objname, ' ');
447
        if (end) {
448
            *end = 0;
449
        }
450
    }
451
    QString cmd = QString::fromLatin1("Gui.Selection.setPreselection("
452
                                      "App.getDocument('%1').getObject('%2'),'%3',tp=2)")
453
                      .arg(QString::fromLatin1(docname),
454
                           QString::fromLatin1(objname),
455
                           QString::fromLatin1(subname));
456
    try {
457
        Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
458
    }
459
    catch (Base::Exception& e) {
460
        e.ReportException();
461
    }
462
}
463

464
void SelectionView::zoom()
465
{
466
    select();
467
    try {
468
        Gui::Command::runCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewSelection\")");
469
    }
470
    catch (Base::Exception& e) {
471
        e.ReportException();
472
    }
473
}
474

475
void SelectionView::treeSelect()
476
{
477
    select();
478
    try {
479
        Gui::Command::runCommand(Gui::Command::Gui, "Gui.runCommand(\"Std_TreeSelection\")");
480
    }
481
    catch (Base::Exception& e) {
482
        e.ReportException();
483
    }
484
}
485

486
void SelectionView::touch()
487
{
488
    QListWidgetItem* item = selectionView->currentItem();
489
    if (!item) {
490
        return;
491
    }
492
    QStringList elements = item->data(Qt::UserRole).toStringList();
493
    if (elements.size() < 2) {
494
        return;
495
    }
496
    QString cmd = QString::fromLatin1(R"(App.getDocument("%1").getObject("%2").touch())")
497
                      .arg(elements[0], elements[1]);
498
    try {
499
        Gui::Command::runCommand(Gui::Command::Doc, cmd.toLatin1());
500
    }
501
    catch (Base::Exception& e) {
502
        e.ReportException();
503
    }
504
}
505

506
void SelectionView::toPython()
507
{
508
    QListWidgetItem* item = selectionView->currentItem();
509
    if (!item) {
510
        return;
511
    }
512
    QStringList elements = item->data(Qt::UserRole).toStringList();
513
    if (elements.size() < 2) {
514
        return;
515
    }
516

517
    try {
518
        QString cmd = QString::fromLatin1(R"(obj = App.getDocument("%1").getObject("%2"))")
519
                          .arg(elements[0], elements[1]);
520
        Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
521
        if (elements.length() > 2) {
522
            App::Document* doc = App::GetApplication().getDocument(elements[0].toLatin1());
523
            App::DocumentObject* obj = doc->getObject(elements[1].toLatin1());
524
            QString property = getProperty(obj);
525

526
            cmd = QString::fromLatin1(R"(shp = App.getDocument("%1").getObject("%2").%3)")
527
                      .arg(elements[0], elements[1], property);
528
            Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
529

530
            if (supportPart(obj, elements[2])) {
531
                cmd = QString::fromLatin1(R"(elt = App.getDocument("%1").getObject("%2").%3.%4)")
532
                          .arg(elements[0], elements[1], property, elements[2]);
533
                Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
534
            }
535
        }
536
    }
537
    catch (const Base::Exception& e) {
538
        e.ReportException();
539
    }
540
}
541

542
void SelectionView::showPart()
543
{
544
    QListWidgetItem* item = selectionView->currentItem();
545
    if (!item) {
546
        return;
547
    }
548
    QStringList elements = item->data(Qt::UserRole).toStringList();
549
    if (elements.length() > 2) {
550
        App::Document* doc = App::GetApplication().getDocument(elements[0].toLatin1());
551
        App::DocumentObject* obj = doc->getObject(elements[1].toLatin1());
552
        QString module = getModule(obj->getTypeId().getName());
553
        QString property = getProperty(obj);
554
        if (!module.isEmpty() && !property.isEmpty() && supportPart(obj, elements[2])) {
555
            try {
556
                Gui::Command::addModule(Gui::Command::Gui, module.toLatin1());
557
                QString cmd =
558
                    QString::fromLatin1(R"(%1.show(App.getDocument("%2").getObject("%3").%4.%5))")
559
                        .arg(module, elements[0], elements[1], property, elements[2]);
560
                Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
561
            }
562
            catch (const Base::Exception& e) {
563
                e.ReportException();
564
            }
565
        }
566
    }
567
}
568

569
QString SelectionView::getModule(const char* type) const
570
{
571
    // go up the inheritance tree and find the module name of the first
572
    // sub-class that has not the prefix "App::"
573
    std::string prefix;
574
    Base::Type typeId = Base::Type::fromName(type);
575

576
    while (!typeId.isBad()) {
577
        std::string temp(typeId.getName());
578
        std::string::size_type pos = temp.find_first_of("::");
579

580
        std::string module;
581
        if (pos != std::string::npos) {
582
            module = std::string(temp, 0, pos);
583
        }
584
        if (module != "App") {
585
            prefix = module;
586
        }
587
        else {
588
            break;
589
        }
590
        typeId = typeId.getParent();
591
    }
592

593
    return QString::fromStdString(prefix);
594
}
595

596
QString SelectionView::getProperty(App::DocumentObject* obj) const
597
{
598
    QString property;
599
    if (obj->isDerivedFrom<App::GeoFeature>()) {
600
        App::GeoFeature* geo = static_cast<App::GeoFeature*>(obj);
601
        const App::PropertyComplexGeoData* data = geo->getPropertyOfGeometry();
602
        const char* name = data ? data->getName() : nullptr;
603
        if (App::Property::isValidName(name)) {
604
            property = QString::fromLatin1(name);
605
        }
606
    }
607

608
    return property;
609
}
610

611
bool SelectionView::supportPart(App::DocumentObject* obj, const QString& part) const
612
{
613
    if (obj->isDerivedFrom<App::GeoFeature>()) {
614
        App::GeoFeature* geo = static_cast<App::GeoFeature*>(obj);
615
        const App::PropertyComplexGeoData* data = geo->getPropertyOfGeometry();
616
        if (data) {
617
            const Data::ComplexGeoData* geometry = data->getComplexData();
618
            std::vector<const char*> types = geometry->getElementTypes();
619
            for (auto it : types) {
620
                if (part.startsWith(QString::fromLatin1(it))) {
621
                    return true;
622
                }
623
            }
624
        }
625
    }
626

627
    return false;
628
}
629

630
void SelectionView::onItemContextMenu(const QPoint& point)
631
{
632
    QListWidgetItem* item = selectionView->itemAt(point);
633
    if (!item) {
634
        return;
635
    }
636
    QMenu menu;
637
    QAction* selectAction = menu.addAction(tr("Select only"), this, [&] {
638
        this->select(nullptr);
639
    });
640
    selectAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-select")));
641
    selectAction->setToolTip(tr("Selects only this object"));
642

643
    QAction* deselectAction = menu.addAction(tr("Deselect"), this, &SelectionView::deselect);
644
    deselectAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-unselectable")));
645
    deselectAction->setToolTip(tr("Deselects this object"));
646

647
    QAction* zoomAction = menu.addAction(tr("Zoom fit"), this, &SelectionView::zoom);
648
    zoomAction->setIcon(QIcon::fromTheme(QString::fromLatin1("zoom-fit-best")));
649
    zoomAction->setToolTip(tr("Selects and fits this object in the 3D window"));
650

651
    QAction* gotoAction = menu.addAction(tr("Go to selection"), this, &SelectionView::treeSelect);
652
    gotoAction->setToolTip(tr("Selects and locates this object in the tree view"));
653

654
    QAction* touchAction = menu.addAction(tr("Mark to recompute"), this, &SelectionView::touch);
655
    touchAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-refresh")));
656
    touchAction->setToolTip(tr("Mark this object to be recomputed"));
657

658
    QAction* toPythonAction =
659
        menu.addAction(tr("To python console"), this, &SelectionView::toPython);
660
    toPythonAction->setIcon(QIcon::fromTheme(QString::fromLatin1("applications-python")));
661
    toPythonAction->setToolTip(
662
        tr("Reveals this object and its subelements in the python console."));
663

664
    QStringList elements = item->data(Qt::UserRole).toStringList();
665
    if (elements.length() > 2) {
666
        // subshape-specific entries
667
        QAction* showPart =
668
            menu.addAction(tr("Duplicate subshape"), this, &SelectionView::showPart);
669
        showPart->setIcon(QIcon(QString::fromLatin1(":/icons/ClassBrowser/member.svg")));
670
        showPart->setToolTip(tr("Creates a standalone copy of this subshape in the document"));
671
    }
672
    menu.exec(selectionView->mapToGlobal(point));
673
}
674

675
void SelectionView::onUpdate()
676
{}
677

678
bool SelectionView::onMsg(const char* /*pMsg*/, const char** /*ppReturn*/)
679
{
680
    return false;
681
}
682

683
void SelectionView::hideEvent(QHideEvent* ev)
684
{
685
    DockWindow::hideEvent(ev);
686
}
687

688
void SelectionView::showEvent(QShowEvent* ev)
689
{
690
    enablePickList->setChecked(Selection().needPickedList());
691
    Gui::DockWindow::showEvent(ev);
692
}
693

694
void SelectionView::onEnablePickList()
695
{
696
    bool enabled = enablePickList->isChecked();
697
    Selection().enablePickedList(enabled);
698
    pickList->setVisible(enabled);
699
}
700

701
/// @endcond
702

703
#include "moc_SelectionView.cpp"
704

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

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

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

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