File: selectionmode.cpp

package info (click to toggle)
openmw 0.50.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,076 kB
  • sloc: cpp: 380,958; xml: 2,192; sh: 1,449; python: 911; makefile: 26; javascript: 5
file content (92 lines) | stat: -rw-r--r-- 3,430 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "selectionmode.hpp"

#include <QAction>
#include <QMenu>

#include <memory>

#include <apps/opencs/view/widget/scenetoolmode.hpp>

#include "worldspacewidget.hpp"

namespace CSVWidget
{
    class SceneToolbar;
}

namespace CSVRender
{
    SelectionMode::SelectionMode(
        CSVWidget::SceneToolbar* parent, WorldspaceWidget& worldspaceWidget, unsigned int interactionMask)
        : SceneToolMode(parent, "Selection mode")
        , mWorldspaceWidget(worldspaceWidget)
        , mInteractionMask(interactionMask)
    {
        addButton(":scenetoolbar/selection-mode-cube", "cube-centre",
            "Centred cube"
            "<ul><li>Drag with {scene-select-primary} for primary select or {scene-select-secondary} for secondary "
            "select "
            "from the centre of the selection cube outwards.</li>"
            "<li>The selection cube is aligned to the word space axis</li>"
            "<li>If context selection mode is enabled, a drag with {scene-edit-primary} or {scene-edit-secondary} not "
            "starting on an instance will have the same effect</li>"
            "</ul>");
        addButton(":scenetoolbar/selection-mode-cube-corner", "cube-corner",
            "Cube corner to corner"
            "<ul><li>Drag with {scene-select-primary} for primary select or {scene-select-secondary} for secondary "
            "select "
            "from one corner of the selection cube to the opposite corner</li>"
            "<li>The selection cube is aligned to the word space axis</li>"
            "<li>If context selection mode is enabled, a drag with {scene-edit-primary} or {scene-edit-secondary} not "
            "starting on an instance will have the same effect</li>"
            "</ul>");
        addButton(":scenetoolbar/selection-mode-cube-sphere", "sphere",
            "Centred sphere"
            "<ul><li>Drag with {scene-select-primary} for primary select or {scene-select-secondary} for secondary "
            "select  "
            "from the centre of the selection sphere outwards</li>"
            "<li>If context selection mode is enabled, a drag with {scene-edit-primary} or {scene-edit-secondary} not "
            "starting on an instance will have the same effect</li>"
            "</ul>");

        mSelectAll = new QAction("Select all", this);
        mDeselectAll = new QAction("Clear selection", this);
        mInvertSelection = new QAction("Invert selection", this);

        connect(mSelectAll, &QAction::triggered, this, &SelectionMode::selectAll);
        connect(mDeselectAll, &QAction::triggered, this, &SelectionMode::clearSelection);
        connect(mInvertSelection, &QAction::triggered, this, &SelectionMode::invertSelection);
    }

    WorldspaceWidget& SelectionMode::getWorldspaceWidget()
    {
        return mWorldspaceWidget;
    }

    bool SelectionMode::createContextMenu(QMenu* menu)
    {
        if (menu)
        {
            menu->addAction(mSelectAll);
            menu->addAction(mDeselectAll);
            menu->addAction(mInvertSelection);
        }

        return true;
    }

    void SelectionMode::selectAll()
    {
        getWorldspaceWidget().selectAll(mInteractionMask);
    }

    void SelectionMode::clearSelection()
    {
        getWorldspaceWidget().clearSelection(mInteractionMask);
    }

    void SelectionMode::invertSelection()
    {
        getWorldspaceWidget().invertSelection(mInteractionMask);
    }
}